annotate lisp/progmodes/ada-mode.el @ 22166:917e237b5e65

(shrink_decoding_region): No short cut by coding->heading_ascii if eol conversion is necessary.
author Kenichi Handa <handa@m17n.org>
date Thu, 21 May 1998 01:48:52 +0000
parents f3f9df46d008
children ff46f1893f6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13231
diff changeset
1 ;;; ada-mode.el --- An Emacs major-mode for editing Ada source.
17996
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
2
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
3 ;; Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
4
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
5 ;; Authors: Rolf Ebert <ebert@inf.enst.fr>
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
6 ;; Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
7 ;; Keywords: languages oop ada
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
8 ;; Rolf Ebert's version: 2.27
17996
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
9
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17929
diff changeset
10 ;; This file is part of GNU Emacs.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13963
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13963
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13963
diff changeset
25 ;; Boston, MA 02111-1307, USA.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; 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
28 ;;; and Ada 95 source code under Emacs-19. It contains completely new
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;; indenting code and support for code browsing (see ada-xref).
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;; USAGE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;; =====
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
34 ;;; Emacs should enter Ada mode when you load an Ada source (*.ad[abs]).
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;; When you have entered ada-mode, you may get more info by pressing
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;; C-h m. You may also get online help describing various functions by:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;; C-h d <Name of function you want described>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;; HISTORY
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;; =======
11199
394f205af26d Fix comments.
Karl Heuer <kwzh@gnu.org>
parents: 10880
diff changeset
43 ;;; The first Ada mode for GNU Emacs was written by V. Broman in
394f205af26d Fix comments.
Karl Heuer <kwzh@gnu.org>
parents: 10880
diff changeset
44 ;;; 1985. He based his work on the already existing Modula-2 mode.
394f205af26d Fix comments.
Karl Heuer <kwzh@gnu.org>
parents: 10880
diff changeset
45 ;;; This was distributed as ada.el in versions of Emacs prior to 19.29.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;;; Lynn Slater wrote an extensive Ada mode in 1989. It consisted of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;; several files with support for dired commands and other nice
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;;; things. It is currently available from the PAL
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;; (wuarchive.wustl.edu:/languages/ada) as ada-mode-1.06a.tar.Z.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;;; The probably very first Ada mode (called electric-ada.el) was
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;;; written by Steven D. Litvintchouk and Steven M. Rosen for the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;;; Gosling Emacs. L. Slater based his development on ada.el and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;; electric-ada.el.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;;; 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
58 ;;; R. Ebert. Some ideas from the Ada mode mailing list have been
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;;; added. Some of the functionality of L. Slater's mode has not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;;; (yet) been recoded in this new mode. Perhaps you prefer sticking
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;;; to his version.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
64 ;;; KNOWN BUGS
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
65 ;;; ==========
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;; In the presence of comments and/or incorrect syntax
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;; ada-format-paramlist produces weird results.
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
69 ;;; -------------------
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
70 ;;; 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
71 ;;; 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
72 ;;; 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
73 ;;; C : constant Character := Character'('"');
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
74 ;;; -------------------
17914
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
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
77 ;;; TODO
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 ;;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
80 ;;; o bodify-single-subprogram
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
81 ;;; 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
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
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
85 ;;; CREDITS
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 ;;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
88 ;;; Many thanks to
13963
a62c62ac5102 (ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
89 ;;; 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
90 ;;; woodruff@stc.llnl.gov (John Woodruff)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
91 ;;; jj@ddci.dk (Jesper Joergensen)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
92 ;;; gse@ocsystems.com (Scott Evans)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
93 ;;; comar@LANG8.CS.NYU.EDU (Cyrille Comar)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
94 ;;; and others for their valuable hints.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;;;--------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;;; USER OPTIONS
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;;;--------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
100
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
101 ;; ---- customize support
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
102
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
103 (defgroup ada nil
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
104 "Major mode for editing Ada source in Emacs"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
105 :group 'languages)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
106
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; ---- configure indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
109 (defcustom ada-indent 3
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
110 "*Defines the size of Ada indentation."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
111 :type 'integer
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
112 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
113
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
114 (defcustom ada-broken-indent 2
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
115 "*# of columns to indent the continuation of a broken line."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
116 :type 'integer
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
117 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
118
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
119 (defcustom ada-label-indent -4
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
120 "*# of columns to indent a label."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
121 :type 'integer
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
122 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
123
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
124 (defcustom ada-stmt-end-indent 0
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 "*# of columns to indent a statement end keyword in a separate line.
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
126 Examples are 'is', 'loop', 'record', ..."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
127 :type 'integer
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
128 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
129
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
130 (defcustom ada-when-indent 3
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
131 "*Defines the indentation for 'when' relative to 'exception' or 'case'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
132 :type 'integer
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
133 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
134
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
135 (defcustom ada-indent-record-rel-type 3
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
136 "*Defines the indentation for 'record' relative to 'type' or 'use'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
137 :type 'integer
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
138 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
139
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
140 (defcustom ada-indent-comment-as-code t
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
141 "*If non-nil, comment-lines get indented as Ada code."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
142 :type 'boolean
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
143 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
144
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
145 (defcustom ada-indent-is-separate t
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
146 "*If non-nil, 'is separate' or 'is abstract' on a single line are indented."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
147 :type 'boolean
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
148 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
149
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
150 (defcustom ada-indent-to-open-paren t
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
151 "*If non-nil, indent according to the innermost open parenthesis."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
152 :type 'boolean
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
153 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
154
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
155 (defcustom ada-search-paren-char-count-limit 3000
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
156 "*Search that many characters for an open parenthesis."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
157 :type 'integer
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
158 :group 'ada)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;; ---- other user options
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
163 (defcustom ada-tab-policy 'indent-auto
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 "*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
165 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
166 or `always-tab'.
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
167
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
168 `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
169 `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
170 `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
171 `indent-af' : use Gary E. Barnes' ada-format.el
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
172 `always-tab' : do indent-relative."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
173 :type '(choice (const indent-auto)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
174 (const indent-rigidly)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
175 (const gei)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
176 (const indent-af)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
177 (const always-tab))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
178 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
179
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
180 (defcustom 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
181 "*If non-nil, `ada-move-to-start' moves point to the subprog declaration,
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
182 not to 'begin'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
183 :type 'boolean
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
184 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
185
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
186 (defcustom ada-spec-suffix ".ads"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
187 "*Suffix of Ada specification files."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
188 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
189 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
190
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
191 (defcustom ada-body-suffix ".adb"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
192 "*Suffix of Ada body files."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
193 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
194 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
195
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
196 (defcustom ada-spec-suffix-as-regexp "\\.ads$"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
197 "*Regexp to find Ada specification files."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
198 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
199 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
200
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
201 (defcustom ada-body-suffix-as-regexp "\\.adb$"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
202 "*Regexp to find Ada body files."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
203 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
204 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
205
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
206 (defvar ada-other-file-alist
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
207 (list
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
208 (list ada-spec-suffix-as-regexp (list ada-body-suffix))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
209 (list ada-body-suffix-as-regexp (list ada-spec-suffix))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
210 )
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
211 "*Alist of extensions to find given the current file's extension.
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
212
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
213 This list should contain the most used extensions before the others,
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
214 since the search algorithm searches sequentially through each directory
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
215 specified in `ada-search-directories'. If a file is not found, a new one
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
216 is created with the first matching extension (`.adb' yields `.ads').")
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
217
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
218 (defcustom ada-search-directories
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
219 '("." "/usr/adainclude" "/usr/local/adainclude" "/opt/gnu/adainclude")
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
220 "*List of directories to search for Ada files.
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
221 See the description for the `ff-search-directories' variable."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
222 :type '(repeat (choice :tag "Directory"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
223 (const :tag "default" nil)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
224 (directory :format "%v")))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
225 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
226
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
227 (defcustom ada-language-version 'ada95
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
228 "*Do we program in `ada83' or `ada95'?"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
229 :type '(choice (const ada83)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
230 (const ada95))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
231 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
232
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
233 (defcustom 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
234 "*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
235 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
236 `capitalize-word'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
237 :type '(choice (const downcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
238 (const upcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
239 (const capitalize-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
240 (const ada-loose-case-word))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
241 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
242
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
243 (defcustom 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
244 "*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
245 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
246 `capitalize-word'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
247 :type '(choice (const downcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
248 (const upcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
249 (const capitalize-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
250 (const ada-loose-case-word))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
251 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
252
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
253 (defcustom 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
254 "*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
255 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
256 `capitalize-word'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
257 :type '(choice (const downcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
258 (const upcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
259 (const capitalize-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
260 (const ada-loose-case-word))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
261 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
262
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
263 (defcustom ada-auto-case t
13963
a62c62ac5102 (ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
264 "*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
265 Casing is done according to `ada-case-keyword', `ada-case-identifier'
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
266 and `ada-case-attribute'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
267 :type 'boolean
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
268 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
269
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
270 (defcustom ada-clean-buffer-before-saving t
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
271 "*If non-nil, `remove-trailing-spaces' and `untabify' buffer before saving."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
272 :type 'boolean
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
273 :group 'ada)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (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
276 "*List of functions to call when Ada mode is invoked.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 This is a good place to add Ada environment specific bindings.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
279 (defcustom ada-external-pretty-print-program "aimap"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
280 "*External pretty printer to call from within Ada mode."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
281 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
282 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
283
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
284 (defcustom ada-tmp-directory "/tmp/"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
285 "*Directory to store the temporary file for the Ada pretty printer."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
286 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
287 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
288
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
289 (defcustom ada-compile-options "-c"
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
290 "*Buffer local options passed to the Ada compiler.
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
291 These options are used when the compiler is invoked on the current buffer."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
292 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
293 :group 'ada)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
294 (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
295
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
296 (defcustom ada-make-options "-c"
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
297 "*Buffer local options passed to `ada-compiler-make' (usually `gnatmake').
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
298 These options are used when `gnatmake' is invoked on the current buffer."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
299 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
300 :group 'ada)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
301 (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
302
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
303 (defcustom ada-compiler-syntax-check "gcc -c -gnats"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
304 "*Compiler command with options for syntax checking."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
305 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
306 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
307
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
308 (defcustom ada-compiler-make "gnatmake"
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
309 "*The `make' command for the given compiler."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
310 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
311 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
312
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
313 (defcustom ada-fill-comment-prefix "-- "
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
314 "*This is inserted in the first columns when filling a comment paragraph."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
315 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
316 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
317
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
318 (defcustom 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
319 "*This is inserted at the end of each line when filling a comment paragraph.
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
320 with `ada-fill-comment-paragraph-postfix'."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
321 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
322 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
323
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
324 (defcustom ada-krunch-args "0"
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
325 "*Argument of gnatkr, a string containing the max number of characters.
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
326 Set to 0, if you don't use crunched filenames."
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
327 :type 'string
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
328 :group 'ada)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 ;;; ---- end of user configurable variables
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (defvar ada-mode-abbrev-table nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 "Abbrev table used in Ada mode.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (define-abbrev-table 'ada-mode-abbrev-table ())
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (defvar ada-mode-map ()
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
338 "Local keymap used for Ada mode.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (defvar ada-mode-syntax-table nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 "Syntax table to be used for editing Ada source code.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
343 (defvar ada-mode-symbol-syntax-table nil
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
344 "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
345
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (defconst ada-83-keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 "\\<\\(abort\\|abs\\|accept\\|access\\|all\\|and\\|array\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 at\\|begin\\|body\\|case\\|constant\\|declare\\|delay\\|delta\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 digits\\|do\\|else\\|elsif\\|end\\|entry\\|exception\\|exit\\|for\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 function\\|generic\\|goto\\|if\\|in\\|is\\|limited\\|loop\\|mod\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 new\\|not\\|null\\|of\\|or\\|others\\|out\\|package\\|pragma\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 private\\|procedure\\|raise\\|range\\|record\\|rem\\|renames\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 return\\|reverse\\|select\\|separate\\|subtype\\|task\\|terminate\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 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
355 ; "\\<\\(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
356 ;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
357 ;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
358 ;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
359 ;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
360 ;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
361 ;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
362 ;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
363 ;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
364 ;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
365 "Regular expression for looking at Ada83 keywords.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
367 (defconst ada-95-keywords
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 "\\<\\(abort\\|abs\\|abstract\\|accept\\|access\\|aliased\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 all\\|and\\|array\\|at\\|begin\\|body\\|case\\|constant\\|declare\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 delay\\|delta\\|digits\\|do\\|else\\|elsif\\|end\\|entry\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 exception\\|exit\\|for\\|function\\|generic\\|goto\\|if\\|in\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 is\\|limited\\|loop\\|mod\\|new\\|not\\|null\\|of\\|or\\|others\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 out\\|package\\|pragma\\|private\\|procedure\\|protected\\|raise\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 range\\|record\\|rem\\|renames\\|requeue\\|return\\|reverse\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 select\\|separate\\|subtype\\|tagged\\|task\\|terminate\\|then\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 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
377 "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
378
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
379 (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
380 "Regular expression for looking at Ada keywords.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (defvar ada-ret-binding nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 "Variable to save key binding of RET when casing is activated.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (defvar ada-lfd-binding nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 "Variable to save key binding of LFD when casing is activated.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 ;;; ---- Regexps to find procedures/functions/packages
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
390 (defconst ada-ident-re
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
391 "[a-zA-Z0-9_\\.]+"
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
392 "Regexp matching Ada (qualified) identifiers.")
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
393
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (defvar ada-procedure-start-regexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\([a-zA-Z0-9_\\.]+\\)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 "Regexp used to find Ada procedures/functions.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (defvar ada-package-start-regexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 "^[ \t]*\\(package\\)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 "Regexp used to find Ada packages")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 ;;; ---- regexps for indentation functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (defvar ada-block-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 "\\<\\(begin\\|select\\|declare\\|private\\|or\\|generic\\|\
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
407 exception\\|loop\\|else\\|\
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
408 \\(\\(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
409 "Regexp for keywords starting Ada blocks.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (defvar ada-end-stmt-re
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
412 "\\(;\\|=>\\|^[ \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
413 \\<\\(begin\\|else\\|record\\|loop\\|select\\|do\\|then\\|\
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
414 declare\\|generic\\|private\\)\\>\\|\
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
415 ^[ \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
416 ^[ \t]*exception\\>\\)"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 "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
418 A new statement starts after these.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (defvar ada-loop-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 "\\<\\(for\\|while\\|loop\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 "Regexp for the start of a loop.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (defvar ada-subprog-start-re
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
425 "\\<\\(procedure\\|protected\\|package\\|function\\|\
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
426 task\\|accept\\|entry\\)\\>"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 "Regexp for the start of a subprogram.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
429 (defvar ada-named-block-re
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
430 "[ \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
431 "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
432
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433
12702
b0355a012c1d (ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 12586
diff changeset
434 ;; 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
435 ;;
b0355a012c1d (ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 12586
diff changeset
436 (defvar ada-imenu-generic-expression
b0355a012c1d (ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 12586
diff changeset
437 '((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
438 ("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
439
b0355a012c1d (ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 12586
diff changeset
440 "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
441
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 ;;;-------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 ;;; functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;;;-------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
446 (defun ada-xemacs ()
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
447 (or (string-match "Lucid" emacs-version)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
448 (string-match "XEmacs" emacs-version)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
449
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (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
451 "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
452 ;; 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
453 ;; `_' 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
454 ;; 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
455 ;; temporarily switch between the two.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (setq ada-mode-syntax-table (make-syntax-table))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (set-syntax-table ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
459 ;; 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
460 ;; 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
461 ;; off the track.)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
462 (modify-syntax-entry ?% "$" ada-mode-syntax-table)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (modify-syntax-entry ?\" "\"" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (modify-syntax-entry ?\# "$" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (modify-syntax-entry ?: "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (modify-syntax-entry ?\; "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (modify-syntax-entry ?& "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (modify-syntax-entry ?\| "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (modify-syntax-entry ?+ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (modify-syntax-entry ?* "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (modify-syntax-entry ?/ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (modify-syntax-entry ?= "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (modify-syntax-entry ?< "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (modify-syntax-entry ?> "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (modify-syntax-entry ?$ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (modify-syntax-entry ?\[ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (modify-syntax-entry ?\] "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (modify-syntax-entry ?\{ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (modify-syntax-entry ?\} "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (modify-syntax-entry ?. "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (modify-syntax-entry ?\\ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (modify-syntax-entry ?\' "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 ;; a single hyphen is punctuation, but a double hyphen starts a comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (modify-syntax-entry ?- ". 12" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 ;; and \f and \n end a comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (modify-syntax-entry ?\f "> " ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (modify-syntax-entry ?\n "> " ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
493 ;; define what belongs in Ada symbols
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (modify-syntax-entry ?_ "_" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 ;; define parentheses to match
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (modify-syntax-entry ?\( "()" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (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
499
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
500 (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
501 (modify-syntax-entry ?_ "w" ada-mode-symbol-syntax-table)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
505 ;;;###autoload
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (defun ada-mode ()
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
507 "Ada mode is the major mode for editing Ada code.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 Bindings are as follows: (Note: 'LFD' is control-j.)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 Indent line '\\[ada-tab]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 Indent line, insert newline and indent the new line. '\\[newline-and-indent]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 Re-format the parameter-list point is in '\\[ada-format-paramlist]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 Indent all lines in region '\\[ada-indent-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 Call external pretty printer program '\\[ada-call-pretty-printer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 Adjust case of identifiers and keywords in region '\\[ada-adjust-case-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 Adjust case of identifiers and keywords in buffer '\\[ada-adjust-case-buffer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 Call EXTERNAL pretty printer (if you have one) '\\[ada-call-pretty-printer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 Fill comment paragraph '\\[ada-fill-comment-paragraph]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 Fill comment paragraph and justify each line '\\[ada-fill-comment-paragraph-justify]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 Fill comment paragraph, justify and append postfix '\\[ada-fill-comment-paragraph-postfix]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
527 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
528 Next package '\\[ada-next-package]' Previous package '\\[ada-previous-package]'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 Goto matching start of current 'end ...;' '\\[ada-move-to-start]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 Goto end of current block '\\[ada-move-to-end]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 Comments are handled using standard GNU Emacs conventions, including:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 Start a comment '\\[indent-for-comment]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 Comment region '\\[comment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 Uncomment region '\\[ada-uncomment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 Continue comment on next line '\\[indent-new-comment-line]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 If you use imenu.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 Display index-menu of functions & procedures '\\[imenu]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 If you use find-file.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 Switch to other file (Body <-> Spec) '\\[ff-find-other-file]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 or '\\[ff-mouse-find-other-file]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 Switch to other file in other window '\\[ada-ff-other-window]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 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
547 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
548 with body stubs.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 If you use ada-xref.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 Goto declaration: '\\[ada-point-and-xref]' on the identifier
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 or '\\[ada-goto-declaration]' with point on the identifier
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 Complete identifier: '\\[ada-complete-identifier]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 Execute Gnatf: '\\[ada-gnatf-current]'"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (kill-all-local-variables)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (make-local-variable 'require-final-newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (setq require-final-newline t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (make-local-variable 'comment-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (setq comment-start "-- ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 ;; comment end must be set because it may hold a wrong value if
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 ;; this buffer had been in another mode before. RE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (make-local-variable 'comment-end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (setq comment-end "")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (make-local-variable 'comment-start-skip) ;; used by autofill
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (setq comment-start-skip "--+[ \t]*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (make-local-variable 'indent-line-function)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (setq indent-line-function 'ada-indent-current-function)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (make-local-variable 'fill-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (setq fill-column 75)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (make-local-variable 'comment-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (setq comment-column 40)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (make-local-variable 'parse-sexp-ignore-comments)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (setq parse-sexp-ignore-comments t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (make-local-variable 'case-fold-search)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (setq case-fold-search t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
588 (make-local-variable 'outline-regexp)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
589 (setq outline-regexp "[^\n\^M]")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
590 (make-local-variable 'outline-level)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
591 (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
592
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
593 (make-local-variable 'fill-paragraph-function)
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
594 (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
595 ;;(make-local-variable 'adaptive-fill-regexp)
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
596
12702
b0355a012c1d (ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 12586
diff changeset
597 (make-local-variable 'imenu-generic-expression)
b0355a012c1d (ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 12586
diff changeset
598 (setq imenu-generic-expression ada-imenu-generic-expression)
20459
90f306f86f5d Use imenu-case-fold-search.
Dave Love <fx@gnu.org>
parents: 18126
diff changeset
599 (setq imenu-case-fold-search t)
12702
b0355a012c1d (ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 12586
diff changeset
600
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
601 (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
602 (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
603 (setq font-lock-defaults
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
604 '((ada-font-lock-keywords
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
605 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
606 nil t
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
607 ((?\_ . "w")(?\. . "w"))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
608 beginning-of-line
18126
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
609 (font-lock-syntactic-keywords . ada-font-lock-syntactic-keywords)))
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
610
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
611 ;; Set up support for find-file.el.
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
612 (make-variable-buffer-local 'ff-other-file-alist)
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
613 (make-variable-buffer-local 'ff-search-directories)
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
614 (setq ff-other-file-alist 'ada-other-file-alist
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
615 ff-search-directories 'ada-search-directories
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
616 ff-pre-load-hooks 'ff-which-function-are-we-in
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
617 ff-post-load-hooks 'ff-set-point-accordingly
f7cc7a56414c Finish installing previous change.
Richard M. Stallman <rms@gnu.org>
parents: 18120
diff changeset
618 ff-file-created-hooks 'ada-make-body))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (setq major-mode 'ada-mode)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (setq mode-name "Ada")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 (use-local-map ada-mode-map)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (if ada-mode-syntax-table
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (set-syntax-table ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 (ada-create-syntax-table))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (if ada-clean-buffer-before-saving
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 ;; remove all spaces at the end of lines in the whole buffer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (add-hook 'local-write-file-hooks 'ada-remove-trailing-spaces)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 ;; convert all tabs to the correct number of spaces.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (add-hook 'local-write-file-hooks 'ada-untabify-buffer)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 ;; add menu 'Ada' to the menu bar
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (ada-add-ada-menu)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 (run-hooks 'ada-mode-hook)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 ;; the following has to be done after running the ada-mode-hook
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 ;; because users might want to set the values of these variable
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 ;; inside the hook (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (cond ((eq ada-language-version 'ada83)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (setq ada-keywords ada-83-keywords))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
648 ((eq ada-language-version 'ada95)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
649 (setq ada-keywords ada-95-keywords)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (if ada-auto-case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (ada-activate-keys-for-case)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 ;;;--------------------------
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
656 ;;; Compile support
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
657 ;;;--------------------------
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
658
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
659 (defun ada-check-syntax ()
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
660 "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
661 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
662 (interactive)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
663 (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
664 (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
665 (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
666 "-gnat83 ")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
667 " " ada-compile-options " "
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
668 (buffer-name)))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
669 (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
670 "enter command for syntax check: "
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
671 compile-command))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
672 (compile compile-command)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
673 ;; restore old compile-command
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
674 (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
675
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
676 (defun ada-make-local ()
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
677 "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
678 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
679 (interactive)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
680 (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
681 (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
682 " " ada-make-options " "
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
683 (buffer-name)))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
684 (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
685 "enter command for local make: "
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
686 compile-command))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
687 (compile compile-command)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
688 ;; restore old compile-command
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
689 (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
690
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
691
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
692
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
693
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
694 ;;;--------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 ;;; Fill Comment Paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 ;;;--------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (defun ada-fill-comment-paragraph-justify ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 "Fills current comment paragraph and justifies each line as well."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (ada-fill-comment-paragraph t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (defun ada-fill-comment-paragraph-postfix ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 "Fills current comment paragraph and justifies each line as well.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 Prompts for a postfix to be appended to each line."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (ada-fill-comment-paragraph t t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (defun ada-fill-comment-paragraph (&optional justify postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 "Fills the current comment paragraph.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 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
714 If POSTFIX and JUSTIFY are non-nil, `ada-fill-comment-postfix' is appended
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 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
716 If `ada-indent-comment-as-code' is non-nil, the paragraph is idented."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (let ((opos (point-marker))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (end-2 nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (indent nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 (ada-fill-comment-old-postfix "")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (fill-prefix nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 ;; check if inside comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (if (not (ada-in-comment-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (error "not inside comment"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 ;; prompt for postfix if wanted
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 (setq ada-fill-comment-postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (read-from-minibuffer "enter new postfix string: "
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 ada-fill-comment-postfix)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 ;; prompt for old postfix to remove if necessary
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (setq ada-fill-comment-old-postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (read-from-minibuffer "enter already existing postfix string: "
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 ada-fill-comment-postfix)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 ;; find limits of paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (message "filling comment paragraph ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 ;; find end of paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (while (and (looking-at "--.*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 (not (looking-at "--[ \t]*$")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (back-to-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (setq end (point-marker))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (goto-char opos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 ;; find begin of paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (while (and (looking-at "--.*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (not (looking-at "--[ \t]*$")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (forward-line -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (back-to-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 ;; get indentation to calculate width for filling
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (setq indent (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (setq begin (point-marker)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 ;; delete old postfix if necessary
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 (while (re-search-forward (concat ada-fill-comment-old-postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 "\n")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 end t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 (replace-match "\n"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 ;; delete leading whitespace and uncomment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (while (re-search-forward "^[ \t]*--[ \t]*" end t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 (replace-match "")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 ;; calculate fill width
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (setq fill-column (- fill-column indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 (length ada-fill-comment-prefix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 (if postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 (length ada-fill-comment-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 ;; fill paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 (fill-region begin (1- end) justify)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 (setq fill-column (+ fill-column indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 (length ada-fill-comment-prefix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (if postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (length ada-fill-comment-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 ;; find end of second last line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 (goto-char end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (forward-line -2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (setq end-2 (point-marker)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 ;; re-comment and re-indent region
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (indent-to indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 (insert ada-fill-comment-prefix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 (while (re-search-forward "\n" (1- end-2) t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (replace-match (concat "\n" ada-fill-comment-prefix))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 (indent-to indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 ;; append postfix if wanted
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 ada-fill-comment-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 ;; append postfix up to there
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (while (re-search-forward "\n" (1- end-2) t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 (replace-match (concat ada-fill-comment-postfix "\n")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 ;; fill last line and append postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 (insert-char ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (- fill-column
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (current-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (length ada-fill-comment-postfix)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (insert ada-fill-comment-postfix))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 ;; delete the extra line that gets inserted somehow(??)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 (goto-char (1- end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 (delete-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 (message "filling comment paragraph ... done")
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
844 (goto-char opos))
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
845 t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 ;;;--------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 ;;; Call External Pretty Printer ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 ;;;--------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 (defun ada-call-pretty-printer ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 "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
854 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
855 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
856 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
857 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
858 `ada-tmp-directory'."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 (let ((filename-with-path buffer-file-name)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (curbuf (current-buffer))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (orgpos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 (mesgbuf nil) ;; for byte-compiling
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 (file-path (file-name-directory buffer-file-name))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 (filename-without-path (file-name-nondirectory buffer-file-name))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 (tmp-file-with-directory
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 (concat ada-tmp-directory
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 (file-name-nondirectory buffer-file-name))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 ;; save buffer in temporary file
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (message "saving current buffer to temporary file ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 (write-file tmp-file-with-directory)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (auto-save-mode nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (message "saving current buffer to temporary file ... done")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 ;; call external pretty printer program
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 (message "running external pretty printer ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 ;; create a temporary buffer for messages of pretty printer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (setq mesgbuf (get-buffer-create "Pretty Printer Messages"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 ;; execute pretty printer on temporary file
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (call-process ada-external-pretty-print-program
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 nil mesgbuf t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 tmp-file-with-directory)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 ;; display messages if there are some
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 (if (buffer-modified-p mesgbuf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 ;; show the message buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (display-buffer mesgbuf t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 ;; kill the message buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (kill-buffer mesgbuf))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (message "running external pretty printer ... done")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 ;; kill current buffer and load pretty printer output
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 ;; or restore old buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 (if (y-or-n-p
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 "Really replace current buffer with pretty printer output ? ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 (set-buffer-modified-p nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 (kill-buffer curbuf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (find-file tmp-file-with-directory))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 (message "old buffer contents restored"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 ;; delete temporary file and restore information of current buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 (delete-file tmp-file-with-directory)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 (set-visited-file-name filename-with-path)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (auto-save-mode t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 (goto-char orgpos)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 ;;;---------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 ;;; auto-casing
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 ;;;---------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 ;; 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
919 ;; modified by RE and MH
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (defun ada-after-keyword-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 ;; returns t if cursor is after a keyword.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 (forward-word -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (and (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 (= (point) (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (not (looking-at "_"))) ; (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (looking-at (concat ada-keywords "[^_]")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
932 (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
933 ;; 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
934 ;; 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
935 ;; are "'".
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (save-excursion
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
937 (if (> (point) 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
938 (and
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
939 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
940 (forward-char 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
941 (looking-at "'"))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
942 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
943 (forward-char -2)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
944 (looking-at "'")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (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
949 "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
950 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
951 `ada-case-attribute'.
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
952 If FORCE-IDENTIFIER is non-nil then also adjust keyword as identifier." ; (MH)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (forward-char -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (if (and (> (point) 1) (not (or (ada-in-string-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (ada-in-comment-p)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
956 (ada-in-char-const-p))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (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
958 (if (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
959 (forward-word -1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
960 (or (= (point) (point-min))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
961 (backward-char 1))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
962 (looking-at "'"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
963 (funcall ada-case-attribute -1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
964 (if (and
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
965 (not force-identifier) ; (MH)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
966 (ada-after-keyword-p))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
967 (funcall ada-case-keyword -1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
968 (funcall ada-case-identifier -1)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (forward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 (defun ada-adjust-case-interactive (arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 (let ((lastk last-command-char))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 (cond ((or (eq lastk ?\n)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (eq lastk ?\r))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 ;; horrible kludge
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 (insert " ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 (ada-adjust-case)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 ;; horrible dekludge
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (delete-backward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 ;; some special keys and their bindings
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 ((eq lastk ?\n)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 (funcall ada-lfd-binding))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 ((eq lastk ?\r)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 (funcall ada-ret-binding))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 ((eq lastk ?\C-i) (ada-tab))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 ((self-insert-command (prefix-numeric-value arg))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 ;; if there is a keyword in front of the underscore
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 ;; then it should be part of an identifier (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 (if (eq lastk ?_)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 (ada-adjust-case t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 (ada-adjust-case))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 (defun ada-activate-keys-for-case ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 ;; save original keybindings to allow swapping ret/lfd
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 ;; when casing is activated
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 ;; 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
1001 ;; be changed again when Ada mode is called more than once (MH)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 (or ada-ret-binding
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 (setq ada-ret-binding (key-binding "\C-M")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 (or ada-lfd-binding
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 (setq ada-lfd-binding (key-binding "\C-j")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 ;; call case modifying function after certain keys.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 (mapcar (function (lambda(key) (define-key
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 ada-mode-map
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 (char-to-string key)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 'ada-adjust-case-interactive)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 '( ?` ?~ ?! ?@ ?# ?$ ?% ?^ ?& ?* ?( ?) ?- ?= ?+ ?[ ?{ ?] ?}
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 ?_ ?\\ ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?? ?/ ?\n 32 ?\r )))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 ;; deleted ?\t from above list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 ;; added by MH
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 (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
1019 "Capitalizes the first letter and the letters following `_'.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 ARG is ignored, it's there to fit the standard casing functions' style."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 (let ((pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (first t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 (skip-chars-backward "a-zA-Z0-9_")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (while (or first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 (search-forward "_" pos t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 (and first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 (setq first nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 (insert-char (upcase (following-char)) 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 (delete-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 (goto-char pos)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 ;; added by MH
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1035 ;; modified by JSH to handle attributes
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 (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
1038 "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
1039 Attention: This function might take very long for big regions !"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 (keywordp nil)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1044 (attribp nil))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1045 (unwind-protect
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1046 (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1047 (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
1048 (goto-char to)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1049 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1050 ;; 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
1051 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1052 (while (re-search-backward
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1053 "[^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
1054 from
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1055 t)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1056 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1057 ;; print status message
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1058 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1059 (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
1060 (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
1061 (forward-char 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1062 (or
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1063 ;; 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
1064 (ada-in-string-or-comment-p)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1065 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1066 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1067 ;; 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
1068 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1069 (setq begin (point))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1070 (setq keywordp (looking-at (concat ada-keywords "[^_]")))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1071 (skip-chars-forward "a-zA-Z0-9_")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1072 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1073 ;; casing according to user-option
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1074 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1075 (if keywordp
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1076 (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
1077 (if attribp
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1078 (funcall ada-case-attribute -1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1079 (funcall ada-case-identifier -1)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1080 (goto-char begin))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1081 (message "adjusting case ... done"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1082 (set-syntax-table ada-mode-syntax-table))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 ;; added by MH
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 (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
1089 "Adjusts the case of all words in the whole buffer.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 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
1091 (interactive "*")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 (ada-adjust-case-region (point-min) (point-max)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 ;;;------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 ;;; Format Parameter Lists ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 ;;;------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 (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
1100 "Reformats a parameter list.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 ATTENTION: 1) Comments inside the list are killed !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 2) If the syntax is not correct (especially, if there are
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 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
1104 In such a case, use `undo', correct the syntax and try again."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 (delend nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 (paramlist nil))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1111 (unwind-protect
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1112 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1113 (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
1114
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1115 ;; check if really inside parameter list
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1116 (or (ada-in-paramlist-p)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1117 (error "not in parameter list"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1118 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1119 ;; find start of current parameter-list
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1120 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1121 (ada-search-ignore-string-comment
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1122 (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
1123 (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
1124 (backward-char 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1125 (setq begin (point))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1126
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1127 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1128 ;; find end of parameter-list
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1129 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1130 (forward-sexp 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1131 (setq delend (point))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1132 (delete-char -1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1133
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1134 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1135 ;; find end of last parameter-declaration
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1136 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1137 (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
1138 (forward-char 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1139 (setq end (point))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1140
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1141 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1142 ;; 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
1143 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1144 (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
1145
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1146 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1147 ;; delete the original parameter-list
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1148 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1149 (delete-region begin (1- delend))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1150
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1151 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1152 ;; insert the new parameter-list
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1153 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1154 (goto-char begin)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1155 (ada-insert-paramlist paramlist))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1156
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1157 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1158 ;; restore syntax-table
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1159 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1160 (set-syntax-table ada-mode-syntax-table)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1161 )))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 (defun ada-scan-paramlist (begin end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 ;; Scans a parameter-list between BEGIN and END and returns a list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 ;; of its contents.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 ;; The list has the following format:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 ;;
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1169 ;; Name of Param in? out? access? Name of Type Default-Exp or nil
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 ;; ( ('Name_Param_1' t nil t Type_Param_1 ':= expression')
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 ;; ('Name_Param_2' nil nil t Type_Param_2 nil) )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 (let ((paramlist (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 (param (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 (notend t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 (apos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 (epos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 (semipos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 ;; loop until end of last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 (while notend
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 ;; find first character of parameter-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 (setq apos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 ;; find last character of parameter-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 (if (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 (ada-search-ignore-string-comment "[ \t\n]*;" nil end t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 (setq epos (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 (setq semipos (cdr match-cons)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 (setq epos end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 ;; read name(s) of parameter(s)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 (looking-at "\\([a-zA-Z0-9_, \t\n]*[a-zA-Z0-9_]\\)[ \t\n]*:[^=]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 (setq param (list (buffer-substring (match-beginning 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 (match-end 1))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 (ada-search-ignore-string-comment ":" nil epos t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 ;; look for 'in'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 (setq apos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 (consp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 (ada-search-ignore-string-comment "\\<in\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 t)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 ;; look for 'out'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 (consp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (ada-search-ignore-string-comment "\\<out\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 t)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 ;;
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1241 ;; look for 'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (consp
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1248 (ada-search-ignore-string-comment "\\<access\\>"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 t)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 ;;
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1254 ;; skip 'in'/'out'/'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 (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
1258 (while (looking-at "\\<\\(in\\|out\\|access\\)\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 (ada-goto-next-non-ws))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1263 ;; read type of parameter
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1265 (looking-at "\\<[a-zA-Z0-9_\\.\\']+\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 (buffer-substring (match-beginning 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 (match-end 0)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 ;; read default-expression, if there is one
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 (goto-char (setq apos (match-end 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 (if (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (ada-search-ignore-string-comment ":="
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 (buffer-substring (car match-cons)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 epos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 ;; add this parameter-declaration to the list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 (setq paramlist (append paramlist (list param)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 ;; check if it was the last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 (if (eq epos end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (setq notend nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (goto-char semipos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 ) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 (reverse paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 (defun ada-insert-paramlist (paramlist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 ;; 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
1306 ;; See doc of `ada-scan-paramlist' for the format.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 (let ((i (length paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 (parlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (typlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 (temp 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 (inp nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 (outp nil)
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1313 (accessp nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 (column nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 (orgpoint 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 (firstcol nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 (while (not (zerop i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 (setq i (1- i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 ;; get max length of parameter-name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 (setq parlen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (if (<= parlen (setq temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 (length (nth 0 (nth i paramlist)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 parlen))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 ;; get max length of type-name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (setq typlen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 (if (<= typlen (setq temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 (length (nth 4 (nth i paramlist)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 typlen))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 ;; is there any 'in' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 (setq inp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 (or inp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 (nth 1 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 ;; is there any 'out' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352 (setq outp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 (or outp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (nth 2 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 ;;
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1357 ;; is there any 'access' ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358 ;;
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1359 (setq accessp
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1360 (or accessp
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 (nth 3 (nth i paramlist))))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 ;; does paramlist already start on a separate line ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 (re-search-backward "^.\\|[^ \t]" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (looking-at "^."))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 ;; yes => re-indent it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 ;; no => insert newline and indent it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376 (newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 (delete-horizontal-space)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 (setq orgpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (setq column (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 (funcall (ada-indent-function) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 (indent-to column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 (insert "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386 (setq firstcol (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 (setq i (length paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (while (not (zerop i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 (setq i (1- i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (setq column firstcol)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 ;; insert parameter-name, space and colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 (insert (nth 0 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 (indent-to (+ column parlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 (insert ": ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 (setq column (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 ;; insert 'in' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 (if (nth 1 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 (insert "in ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 (or inp
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1411 accessp)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (insert " ")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 ;; insert 'out' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 (if (nth 2 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (insert "out ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (or outp
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1422 accessp)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (insert " ")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 ;;
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1427 ;; insert 'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 (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
1430 (insert "access "))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 (setq column (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1434 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 ;; insert type-name and, if necessary, space and default-expression
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 (insert (nth 4 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 (if (nth 5 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440 (indent-to (+ column typlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 (insert (nth 5 (nth i paramlist)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1442
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1444 ;; check if it was the last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1445 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446 (if (not (zerop i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 ;; no => insert ';' and newline and indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (insert ";")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 (newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 (indent-to firstcol))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 ;; yes
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 (insert ")"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 ) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 ;; if anything follows, except semicolon:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 ;; put it in a new line and indent it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (if (not (looking-at "[ \t]*[;\n]"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 (ada-indent-newline-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 ;;;----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 ;;; Move To Matching Start/End ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 ;;;----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 (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
1472 "Moves point to the matching start of the current Ada structure."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 (let ((pos (point)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1475 (unwind-protect
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1476 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1477 (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
1478
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1479 (message "searching for block start ...")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1480 (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1481 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1482 ;; 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
1483 ;; or if an error occurs during processing
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1484 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1485 (or
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1486 (ada-in-string-or-comment-p)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1487 (and (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1488 (or (looking-at "[ \t]*\\<end\\>")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1489 (backward-word 1))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1490 (or (looking-at "[ \t]*\\<end\\>")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1491 (backward-word 1))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1492 (or (looking-at "[ \t]*\\<end\\>")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1493 (error "not on end ...;")))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1494 (ada-goto-matching-start 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1495 (setq pos (point))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1496
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1497 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1498 ;; 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
1499 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1500 ada-move-to-declaration
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1501 (looking-at "\\<begin\\>")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1502 (ada-goto-matching-decl-start)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1503 (setq pos (point))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1504
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1505 ) ; end of save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1506
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1507 ;; now really move to the found position
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1508 (goto-char pos)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1509 (message "searching for block start ... done"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1510
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1512 ;; restore syntax-table
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1513 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1514 (set-syntax-table ada-mode-syntax-table))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 (defun ada-move-to-end ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 "Moves point to the matching end of the current block around point.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 Moves to 'begin' if in a declarative part."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 (let ((pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 (decstart nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 (packdecl nil))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1524 (unwind-protect
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1525 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1526 (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
1527
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1528 (message "searching for block end ...")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1529 (save-excursion
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 (forward-char 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1532 (cond
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1533 ;; directly on 'begin'
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 (ada-goto-previous-word)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1536 (looking-at "\\<begin\\>"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1537 (ada-goto-matching-end 1))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1538 ;; on first line of defun declaration
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1539 ((save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1540 (and (ada-goto-stmt-start)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1541 (looking-at "\\<function\\>\\|\\<procedure\\>" )))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1542 (ada-search-ignore-string-comment "\\<begin\\>"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1543 ;; on first line of task declaration
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1544 ((save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1545 (and (ada-goto-stmt-start)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1546 (looking-at "\\<task\\>" )
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1547 (forward-word 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1548 (ada-search-ignore-string-comment "[^ \n\t]")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1549 (not (backward-char 1))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1550 (looking-at "\\<body\\>")))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1551 (ada-search-ignore-string-comment "\\<begin\\>"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1552 ;; accept block start
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1553 ((save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1554 (and (ada-goto-stmt-start)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1555 (looking-at "\\<accept\\>" )))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1556 (ada-goto-matching-end 0))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1557 ;; package start
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1558 ((save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1559 (and (ada-goto-matching-decl-start t)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1560 (looking-at "\\<package\\>")))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1561 (ada-goto-matching-end 1))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1562 ;; inside a 'begin' ... 'end' block
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1563 ((save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1564 (ada-goto-matching-decl-start t))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1565 (ada-search-ignore-string-comment "\\<begin\\>"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1566 ;; (hopefully ;-) everything else
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1567 (t
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1568 (ada-goto-matching-end 1)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1569 (setq pos (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 ) ; end of save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1572
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1573 ;; now really move to the found position
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1574 (goto-char pos)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1575 (message "searching for block end ... done"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1576
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1577 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1578 ;; restore syntax-table
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1579 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1580 (set-syntax-table ada-mode-syntax-table))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 ;;;-----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 ;;; Functions For Indentation ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 ;;;-----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 ;; ---- main functions for indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 (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
1590 "Indents the region using `ada-indent-current' on each line."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 (goto-char beg)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1593 (let ((block-done 0)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1594 (lines-remaining (count-lines beg end))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1595 (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
1596 (count-lines beg end)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1597 (endmark (copy-marker end)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1598 ;; catch errors while indenting
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1599 (condition-case err
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1600 (while (< (point) endmark)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1601 (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
1602 (progn (message msg lines-remaining)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1603 (setq block-done 0)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1604 (if (looking-at "^$") nil
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1605 (ada-indent-current))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1606 (forward-line 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1607 (setq block-done (1+ block-done))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1608 (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
1609 ;; 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
1610 (error
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1611 (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
1612 (message "indenting ... done")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 (defun ada-indent-newline-indent ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 "Indents the current line, inserts a newline and then indents the new line."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 (interactive "*")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1618 (ada-indent-current)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1619 (newline)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1620 (ada-indent-current))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623 (defun ada-indent-current ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 "Indents current line as Ada code.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 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
1626 1) It moves point to the end of the previous code line.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627 Then it calls the function to calculate the indentation for the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 following line as if a newline would be inserted there.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 The calculated column # is saved and the old position of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 is restored.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 2) Then another function is called to calculate the indentation for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632 the current line, based on the previously calculated column #."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1633
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1636 (unwind-protect
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1637 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1638 (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
1639
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1640 (let ((line-end)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1641 (orgpoint (point-marker))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1642 (cur-indent)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1643 (prev-indent)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1644 (prevline t))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1645
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1646 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1647 ;; first step
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1648 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1649 (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1650 (if (ada-goto-prev-nonblank-line t)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1651 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1652 ;; 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
1653 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1654 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1655 ;;(end-of-line)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1656 ;;(forward-char 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1657 ;; we are already at the BOL
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1658 (forward-line 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1659 (setq line-end (point))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1660 (setq prev-indent
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1661 (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1662 (funcall (ada-indent-function) line-end))))
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1663 (progn ; first line of buffer -> set indent
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1664 (beginning-of-line) ; to 0
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1665 (delete-horizontal-space)
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1666 (setq prevline nil))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1667
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1668 (if prevline
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1669 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1670 ;; 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
1671 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1672 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1673 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1674 ;; second step
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1675 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1676 (back-to-indentation)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1677 (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
1678 ;; 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
1679 (if (= (current-column) cur-indent)
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1680 nil
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1681 (delete-horizontal-space)
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1682 (indent-to cur-indent))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1683 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1684 ;; restore position of point
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1685 ;;
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1686 (goto-char orgpoint)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1687 (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
1688 (back-to-indentation))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1691 ;; restore syntax-table
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1693 (set-syntax-table ada-mode-syntax-table)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1694
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1695
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1696 (defun ada-get-current-indent (prev-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1697 ;; Returns the column # to indent the current line to.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 ;; PREV-INDENT is the indentation resulting from the previous lines.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699 (let ((column nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 ;; in open parenthesis, but not in parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 ada-indent-to-open-paren
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 (not (ada-in-paramlist-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 (setq column (ada-in-open-paren-p)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711 ;; check if we have something like this (Table_Component_Type =>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712 ;; Source_File_Record,)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 (if (and (ada-search-ignore-string-comment "[^ \t]" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1715 (looking-at "\n")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1716 (ada-search-ignore-string-comment "[^ \t\n]" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1717 (looking-at ">"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1718 (setq column (+ ada-broken-indent column))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1722 ;; end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1723 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1724 ((looking-at "\\<end\\>")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1725 (let ((label 0))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1726 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1727 (ada-goto-matching-start 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1728
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1729 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1730 ;; 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
1731 ;; 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
1732 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1733 (if (and
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1734 (looking-at "\\<loop\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1735 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1736 (back-to-indentation)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1737 (not (looking-at "\\<loop\\>"))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1738 (if (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1739 (and
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1740 (setq match-cons
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1741 (ada-search-ignore-string-comment
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1742 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
1743 (not (looking-at "\\<loop\\>"))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1744 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1745 (goto-char (car match-cons))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1746 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1747 (beginning-of-line)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1748 (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
1749 (setq label (- ada-label-indent)))))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1750
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1751 (+ (current-indentation) label))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 ;; exception
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 ((looking-at "\\<exception\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1759 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1760 ;; when
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762 ((looking-at "\\<when\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 (+ (current-indentation) ada-when-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 ;; else
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 ((looking-at "\\<else\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 (looking-at "\\<or\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 (ada-goto-matching-start 1 nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 (current-indentation))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 ;; elsif
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1780 ((looking-at "\\<elsif\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782 (ada-goto-matching-start 1 nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1784 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1785 ;; then
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 ((looking-at "\\<then\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 (looking-at "\\<and\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (ada-search-ignore-string-comment "\\<elsif\\>\\|\\<if\\>" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 (+ (current-indentation) ada-stmt-end-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 ;; loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 ((looking-at "\\<loop\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 (setq pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1800 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 (if (looking-at "\\<loop\\>\\|\\<if\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (if (not (looking-at ada-loop-start-re))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (ada-search-ignore-string-comment ada-loop-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 nil pos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (if (looking-at "\\<loop\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1810 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 (+ (current-indentation) ada-stmt-end-indent))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813 ;; begin
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1815 ((looking-at "\\<begin\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1817 (if (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 (current-indentation)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1819 prev-indent)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 ;; is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 ((looking-at "\\<is\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825 ada-indent-is-separate
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 (ada-goto-next-non-ws (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 (looking-at "\\<abstract\\>\\|\\<separate\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1835 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (+ (current-indentation) ada-stmt-end-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 ;; record
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 ((looking-at "\\<record\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 "\\<\\(type\\|use\\)\\>" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845 (if (looking-at "\\<use\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1846 (ada-search-ignore-string-comment "\\<for\\>" t nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1847 (+ (current-indentation) ada-indent-record-rel-type)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849 ;; or as statement-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851 ((ada-looking-at-semi-or)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856 ;; private as statement-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1857 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1858 ((ada-looking-at-semi-private)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1860 (ada-goto-matching-decl-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1861 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1862 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1863 ;; new/abstract/separate
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1864 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1865 ((looking-at "\\<\\(new\\|abstract\\|separate\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1866 (- prev-indent ada-indent (- ada-broken-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1867 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1868 ;; return
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1869 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1870 ((looking-at "\\<return\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1871 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1872 (forward-sexp -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1873 (if (and (looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1874 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1875 (backward-sexp 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1876 (looking-at "\\<function\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1877 (1+ (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 prev-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1879 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1880 ;; do
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1881 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1882 ((looking-at "\\<do\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1883 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1885 (+ (current-indentation) ada-stmt-end-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1886 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1887 ;; package/function/procedure
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1888 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1889 ((and (looking-at "\\<\\(package\\|function\\|procedure\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1890 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1891 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1892 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1893 (looking-at "\\<\\(package\\|function\\|procedure\\)\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1894 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1895 ;; look for 'generic'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1896 (if (and (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1897 (looking-at "generic"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1898 (current-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1899 prev-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1900 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1901 ;; label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1902 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1903 ((looking-at "\\<[a-zA-Z0-9_]+[ \t\n]*:[^=]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1904 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1905 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1906 (+ prev-indent ada-label-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1907 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 ;; identifier and other noindent-statements
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 ((looking-at "\\<[a-zA-Z0-9_]+[ \t\n]*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911 prev-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 ;; beginning of a parameter list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1915 ((looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916 prev-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 ;; end of a parameter list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 ((looking-at ")")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 (backward-sexp 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924 (current-column)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1925 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 ;; comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928 ((looking-at "--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1929 (if ada-indent-comment-as-code
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1930 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 ;; unknown syntax - maybe this should signal an error ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 prev-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1938
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939 (defun ada-indent-function (&optional nomove)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 ;; Returns the function to calculate the indentation for the current
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 ;; line according to the previous statement, ignoring the contents
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 ;; of the current line after point. Moves point to the beginning of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 ;; the current statement, if NOMOVE is nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945 (let ((orgpoint (point))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1946 (func nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 ;; inside a parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 (if (ada-in-paramlist-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (setq func 'ada-get-indent-paramlist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 ;; move to beginning of current statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1956 (if (not nomove)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1957 (ada-goto-stmt-start))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1958 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1959 ;; no beginning found => don't change indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1961 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1962 (eq orgpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1963 (not nomove))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1964 (setq func 'ada-get-indent-nochange)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1968 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 ada-indent-to-open-paren
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 (ada-in-open-paren-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 (setq func 'ada-get-indent-open-paren))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1972 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1973 ((looking-at "\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1974 (setq func 'ada-get-indent-end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1975 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 ((looking-at ada-loop-start-re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 (setq func 'ada-get-indent-loop))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1979 ((looking-at ada-subprog-start-re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1980 (setq func 'ada-get-indent-subprog))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1981 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1982 ((looking-at ada-block-start-re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1983 (setq func 'ada-get-indent-block-start))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1985 ((looking-at "\\<type\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 (setq func 'ada-get-indent-type))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1988 ((looking-at "\\<\\(els\\)?if\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 (setq func 'ada-get-indent-if))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 ((looking-at "\\<case\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1992 (setq func 'ada-get-indent-case))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1994 ((looking-at "\\<when\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1995 (setq func 'ada-get-indent-when))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1996 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1997 ((looking-at "--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1998 (setq func 'ada-get-indent-comment))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1999 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2000 ((looking-at "[a-zA-Z0-9_]+[ \t\n]*:[^=]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2001 (setq func 'ada-get-indent-label))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2002 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2003 ((looking-at "\\<separate\\>")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2004 (setq func 'ada-get-indent-nochange))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2006 (setq func 'ada-get-indent-noindent))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2008 func))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 ;; ---- functions to return indentation for special cases
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2012
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2013 (defun ada-get-indent-open-paren (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2014 ;; 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
2015 ;; Assumes point to be behind an open parenthesis not yet closed.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 (ada-in-open-paren-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2017
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2018
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2019 (defun ada-get-indent-nochange (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2020 ;; Returns the indentation (column #) of the current line.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2021 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2022 (forward-line -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2025
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2026 (defun ada-get-indent-paramlist (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2027 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2028 ;; Assumes point to be inside a parameter-list.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2029 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030 (ada-search-ignore-string-comment "[^ \t\n]" t nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2032 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 ;; in front of the first parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035 ((looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2036 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2037 (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2038 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 ;; in front of another parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2040 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 ((looking-at ";")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2042 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2043 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2044 (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 ;; inside a parameter declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2047 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2048 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2049 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2050 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2051 (+ (current-column) ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2052
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2053
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2054 (defun ada-get-indent-end (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2055 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2056 ;; Assumes point to be at the beginning of an end-statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2057 ;; Therefore it has to find the corresponding start. This can be a little
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2058 ;; slow, if it has to search through big files with many nested blocks.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2059 ;; Signals an error if the corresponding block-start doesn't match.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 (let ((defun-name nil)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2061 (label 0)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2062 (indent nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2063 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2064 ;; is the line already terminated by ';' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2065 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2066 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2067 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2068 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2069 ;; yes, look what's following 'end'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2070 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2071 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2072 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2073 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2074 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2075 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2076 ;; loop/select/if/case/record/select
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2077 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2078 ((looking-at "\\<\\(loop\\|select\\|if\\|case\\|record\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2079 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2080 (ada-check-matching-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2081 (buffer-substring (match-beginning 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2082 (match-end 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2083 (if (looking-at "\\<\\(loop\\|record\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2084 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2085 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2086 (ada-goto-stmt-start)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2087 ;; a label ? => skip it
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2088 (if (looking-at ada-named-block-re)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2089 (progn
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2090 (setq label (- ada-label-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2091 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2092 (ada-goto-next-non-ws)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2093 ;; really looking-at the right thing ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2094 (or (looking-at (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2095 "loop\\|select\\|if\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2096 "record\\|while\\|type\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2097 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2098 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2099 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2100 "loop\\|select\\|if\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2101 "record\\|while\\|type\\)\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102 (backward-word 1))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2103 (+ (current-indentation) label)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2104 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2105 ;; a named block end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2107 ((looking-at ada-ident-re)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 (setq defun-name (buffer-substring (match-beginning 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 (match-end 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111 (ada-goto-matching-start 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112 (ada-check-defun-name defun-name)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2113 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2115 ;; a block-end without name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 ((looking-at ";")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2118 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2119 (ada-goto-matching-start 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120 (if (looking-at "\\<begin\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 (setq indent (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 (if (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124 (current-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2125 indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2126 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2127 ;; anything else - should maybe signal an error ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2128 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2129 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 (+ (current-indentation) ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2131
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 (+ (current-indentation) ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2133
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2134
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 (defun ada-get-indent-case (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 ;; 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
2137 ;; Assumes point to be at the beginning of a case-statement.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2138 (let ((cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2139 (match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2140 (opos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2143 ;; case..is..when..=>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2144 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 ((save-excursion
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2146 (setq match-cons (and
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2147 ;; 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
2148 (ada-search-ignore-string-comment
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2149 "\\<is\\>" nil orgpoint)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2150 (ada-search-ignore-string-comment
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2151 "[ \t\n]+=>" nil orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2154 (if (not (ada-search-ignore-string-comment "\\<when\\>" t opos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 (error "missing 'when' between 'case' and '=>'"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 (+ (current-indentation) ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2157 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2158 ;; case..is..when
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2159 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2160 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2161 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162 "\\<when\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 (goto-char (cdr match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 (+ (current-indentation) ada-broken-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2166 ;; case..is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2168 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2169 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2170 "\\<is\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2171 (+ (current-indentation) ada-when-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2172 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2173 ;; incomplete case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2174 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2175 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 (+ (current-indentation) ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179 (defun ada-get-indent-when (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2180 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2181 ;; Assumes point to be at the beginning of an when-statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 (let ((cur-indent (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2183 (if (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2184 "[ \t\n]+=>" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2185 (+ cur-indent ada-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2186 (+ cur-indent ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2188
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189 (defun ada-get-indent-if (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 ;; Assumes point to be at the beginning of an if-statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2192 (let ((cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2193 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2195 ;; if..then ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197 (if (ada-search-but-not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2198 "\\<then\\>" "\\<and\\>[ \t\n]+\\<then\\>" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2199
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2200 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202 ;; 'then' first in separate line ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 ;; => indent according to 'then'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 (looking-at "\\<then\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2208 (setq cur-indent (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2211 ;; something follows 'then' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2212 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2213 (if (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2214 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2215 "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2216 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2217 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2218 (+ ada-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219 (- cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2220 (funcall (ada-indent-function t) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 (+ cur-indent ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2224 (+ cur-indent ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 (defun ada-get-indent-block-start (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2228 ;; Returns the indentation (column #) for the new line after
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2229 ;; ORGPOINT. Assumes point to be at the beginning of a block start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2230 ;; keyword.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2231 (let ((cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2232 (pos nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2233 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2234 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2235 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2236 (setq pos (car (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2237 "[^ \t\n]" nil orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2238 (goto-char pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2239 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2240 (funcall (ada-indent-function t) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2241 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2242 ;; nothing follows the block-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2243 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2244 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245 (+ (current-indentation) ada-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2246
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2247
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2248 (defun ada-get-indent-subprog (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2249 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2250 ;; Assumes point to be at the beginning of a subprog-/package-declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 (let ((match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 (cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 (foundis nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 (addind 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 (fstart (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 ;; is there an 'is' in front of point ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (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
2262 "\\<\\(is\\|do\\)\\>" nil orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 ;; yes, then skip to its end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267 (setq foundis t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268 (goto-char (cdr match-cons)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270 ;; no, then goto next non-ws, if there is one in front of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273 (if (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (goto-char orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 ;; nothing follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2281 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2282 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 (not (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 "[^ \t\n]" nil orgpoint t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 (+ cur-indent ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2287 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 ;; is abstract/separate/new ...
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2292 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295 "\\<\\(separate\\|new\\|abstract\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 nil orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 (goto-char (car match-cons))
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
2298 (ada-search-ignore-string-comment ada-subprog-start-re t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 (ada-get-indent-noindent orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2300 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301 ;; something follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2302 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2304 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2306 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 (funcall (ada-indent-function t) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2310 ;; no 'is' but ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2311 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2312 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2313 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2314 cur-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2315 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2316 ;; no 'is' or ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2318 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2319 (+ cur-indent ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2321
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2322 (defun ada-get-indent-noindent (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2323 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324 ;; 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
2325 (let ((label 0))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2326 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2327 (beginning-of-line)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2328 (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
2329 (setq label (- ada-label-indent))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2330 (if (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2331 (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
2332 (+ (current-indentation) label)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2333 (+ (current-indentation) ada-broken-indent label))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2335
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2336 (defun ada-get-indent-label (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 ;; Assumes point to be at the beginning of a label or variable declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339 ;; Checks the context to decide if it's a label or a variable declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 ;; This check might be a bit slow.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2341 (let ((match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 (cur-indent (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 (goto-char (cdr (ada-search-ignore-string-comment ":")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 ;; loop label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2348 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2349 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2350 ada-loop-start-re nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2351 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2352 (ada-get-indent-loop orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2353 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 ;; declare label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357 (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
2358 "\\<declare\\|begin\\>" nil orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361 (+ (current-indentation) ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363 ;; complete statement following colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2364 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 cur-indent ; variable-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2369 (- cur-indent ada-label-indent))) ; label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2371 ;; broken statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2373 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376 (+ cur-indent ada-broken-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2377 (+ cur-indent ada-broken-indent (- ada-label-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2379 ;; nothing follows colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2381 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2382 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2383 (+ cur-indent ada-broken-indent) ; variable-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2384 (- cur-indent ada-label-indent)))))) ; label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2385
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2386
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2387 (defun ada-get-indent-loop (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2388 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2389 ;; Assumes point to be at the beginning of a loop statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2390 ;; or (unfortunately) also a for ... use statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2391 (let ((match-cons nil)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2392 (pos (point))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2393 (label (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2394 (beginning-of-line)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2395 (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
2396 (- ada-label-indent)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2397 0))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2398
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2399 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2400
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2401 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 ;; statement complete
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2404 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2405 (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
2406 (+ (current-indentation) label))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2407 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2408 ;; simple loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 ((looking-at "loop\\>")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2411 (+ (ada-get-indent-block-start orgpoint) label))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2412
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2413 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 ;; 'for'- loop (or also a for ... use statement)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2416 ((looking-at "for\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2417 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2418 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2419 ;; for ... use
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2420 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2421 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2422 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2423 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425 (not (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2426 (not (zerop (skip-chars-forward "_a-zA-Z0-9'")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 (not (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2429 (looking-at "\\<use\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 ;; check if there is a 'record' before point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2434 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 "\\<record\\>" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2437 (if match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438 (goto-char (car match-cons)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2439 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2440 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 ;; for..loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2443 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2444 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2445 "\\<loop\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2446 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2447 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2448 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 ;; otherwise to 'for'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2451 (if (not (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2452 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 (looking-at "\\<loop\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2454 (goto-char pos))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2455 (+ (current-indentation) ada-indent label))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2456 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457 ;; for-statement is broken
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2458 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 (t
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2460 (+ (current-indentation) ada-broken-indent label))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 ;; 'while'-loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465 ((looking-at "while\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 ;; while..loop ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2468 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2469 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2470 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2471 "\\<loop\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2477 ;; otherwise to 'while'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 (if (not (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2480 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 (looking-at "\\<loop\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 (goto-char pos))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2483 (+ (current-indentation) ada-indent label))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2484
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2485 (+ (current-indentation) ada-broken-indent label))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 (defun ada-get-indent-type (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 ;; Assumes point to be at the beginning of a type statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2491 (let ((match-dat nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494 ;; complete record declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2495 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 (setq match-dat (ada-search-ignore-string-comment "\\<end\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502 (looking-at "\\<record\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2503 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 (looking-at ";")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 ;; record type
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (setq match-dat (ada-search-ignore-string-comment "\\<record\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2516 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2518 ;; complete type declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2519 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2520 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2521 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2522 (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2523 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2524 ;; "type ... is", but not "type ... is ...", which is broken
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 ((save-excursion
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2527 (and
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2528 (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
2529 (not (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2530 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2532 ;; broken statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2534 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2535 (+ (current-indentation) ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2536
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2538 ;;; ---- support-functions for indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2539
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2540 ;;; ---- searching and matching
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2541
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2542 (defun ada-goto-stmt-start (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2543 ;; Moves point to the beginning of the statement that point is in or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2544 ;; after. Returns the new position of point. Beginnings are found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545 ;; by searching for 'ada-end-stmt-re' and then moving to the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546 ;; following non-ws that is not a comment. LIMIT is actually not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547 ;; used by the indentation functions.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 (let ((match-dat nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 (orgpoint (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (setq match-dat (ada-search-prev-end-stmt limit))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 (if match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2553 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2554 ;; found a previous end-statement => check if anything follows
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2555 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2556 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557 (if (not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2558 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2559 (goto-char (cdr match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2560 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 "[^ \t\n]" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2563 ;; nothing follows => it's the end-statement directly in
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564 ;; front of point => search again
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 (setq match-dat (ada-search-prev-end-stmt limit)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567 ;;
13963
a62c62ac5102 (ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
2568 ;; if found the correct end-statement => goto next non-ws
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2569 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2570 (if match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2571 (goto-char (cdr match-dat)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2572 (ada-goto-next-non-ws))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2573
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 ;; no previous end-statement => we are at the beginning of the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2576 ;; accessible part of the buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2577 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 ;; skip to the very first statement, if there is one
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583 (if (setq match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585 "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (goto-char orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2590 (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2592
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 (defun ada-search-prev-end-stmt (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 ;; Moves point to previous end-statement. Returns a cons cell whose
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 ;; car is the beginning and whose cdr the end of the match.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596 ;; End-statements are defined by 'ada-end-stmt-re'. Checks for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2597 ;; certain keywords if they follow 'end', which means they are no
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 ;; end-statement there.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2599 (let ((match-dat nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2600 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2601 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2602 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2603 ;; search until found or beginning-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2604 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2605 (while
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2606 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 (setq match-dat (ada-search-ignore-string-comment ada-end-stmt-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 limit)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 (if (not (ada-in-open-paren-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 ;; check if there is an 'end' in front of the match
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2617 (if (not (and
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2618 (looking-at
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2619 "\\<\\(record\\|loop\\|select\\|else\\|then\\)\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2620 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2621 (ada-goto-previous-word)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2622 (looking-at "\\<\\(end\\|or\\|and\\)\\>"))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2623 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2624 (goto-char (cdr match-dat))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2625 (ada-goto-next-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2626 (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
2627 (setq found t)))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2628
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
2629 (forward-word -1)))) ; end of loop
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2631 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2635
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2636 (defun ada-goto-next-non-ws (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637 ;; Skips whitespaces, newlines and comments to next non-ws
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 ;; character. Signals an error if there is no more such character
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2639 ;; and limit is nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640 (let ((match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2642 "[^ \t\n]" nil limit t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 (if match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2644 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2645 (if (not limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 (error "no more non-ws")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2648
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2649
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 (defun ada-goto-stmt-end (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 ;; Moves point to the end of the statement that point is in or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2652 ;; before. Returns the new position of point or nil if not found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653 (if (ada-search-ignore-string-comment ada-end-stmt-re nil limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 (point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2655 nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2656
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2658 (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
2659 ;; 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
2660 ;; If BACKWARD is non-nil, jump to the beginning of the previous word.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2661 ;; Returns the new position of point or nil if not found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2662 (let ((match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (orgpoint (point)))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2664 (if (not backward)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2665 (skip-chars-forward "_a-zA-Z0-9\\."))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2666 (if (setq match-cons
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2667 (ada-search-ignore-string-comment "\\w" backward nil t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2668 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2669 ;; move to the beginning of the word found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2670 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2671 (progn
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2672 (goto-char (car match-cons))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2673 (skip-chars-backward "_a-zA-Z0-9")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2674 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2675 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2676 ;; if not found, restore old position of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2677 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2679 (goto-char orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2680 'nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2681
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2682
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2683 (defun ada-goto-previous-word ()
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2684 ;; 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
2685 ;; 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
2686 (ada-goto-next-word t))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2687
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2688
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2689 (defun ada-check-matching-start (keyword)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2690 ;; Signals an error if matching block start is not KEYWORD.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2691 ;; Moves point to the matching block start.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 (ada-goto-matching-start 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2693 (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
2694 (error "matching start is not '%s'" keyword)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2696
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2697 (defun ada-check-defun-name (defun-name)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2698 ;; Checks if the name of the matching defun really is DEFUN-NAME.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2699 ;; Assumes point to be already positioned by 'ada-goto-matching-start'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700 ;; Moves point to the beginning of the declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2701
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2702 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2703 ;; named block without a `declare'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2705 (if (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2706 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2707 (looking-at (concat "\\<" defun-name "\\> *:")))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2708 t ; do nothing
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2709 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2710 ;; 'accept' or 'package' ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2711 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2712 (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
2713 (ada-goto-matching-decl-start))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2714 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2715 ;; '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
2716 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2717 (save-excursion
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2718 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2719 ;; a named 'declare'-block ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2720 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2721 (if (looking-at "\\<declare\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2722 (ada-goto-stmt-start)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2723 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2724 ;; no, => 'procedure'/'function'/'task'/'protected'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2725 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2726 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2727 (forward-word 2)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2728 (backward-word 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2729 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2730 ;; skip 'body' 'type'
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2731 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2732 (if (looking-at "\\<\\(body\\|type\\)\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2733 (forward-word 1))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2734 (forward-sexp 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2735 (backward-sexp 1)))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2736 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2737 ;; 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
2738 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2739 (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
2740 (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
2741 (buffer-substring (point)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2742 (progn (forward-sexp 1) (point))))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2743
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2744
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2745 (defun ada-goto-matching-decl-start (&optional noerror nogeneric)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2746 ;; Moves point to the matching declaration start of the current 'begin'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2747 ;; If NOERROR is non-nil, it only returns nil if no match was found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2748 (let ((nest-count 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2749 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2750 (first t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2751 (flag nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2752 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2753 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2755 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2756 (not (zerop nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2757 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2758 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2759 "is\\|separate\\|end\\|declare\\|new\\|begin\\|generic"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2760 "\\)\\>") t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2761 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2762 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2763 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2764 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2765 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 ((looking-at "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767 (ada-goto-matching-start 1 noerror)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2768 (if (looking-at "begin")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2769 (setq nest-count (1+ nest-count))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2770 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2771 ((looking-at "declare\\|generic")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2772 (setq nest-count (1- nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2773 (setq first nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2774 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2775 ((looking-at "is")
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
2776 ;; 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
2777 ;; 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
2778 (if (or (looking-at "is +<>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2779 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2780 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2781 (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
2782 (if (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2783 (backward-char 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2784 (looking-at ")"))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2785 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2786 (forward-char 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2787 (backward-sexp 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2788 (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
2789 ))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2790 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2791 (and
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2792 (looking-at "\\<type\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2793 (save-match-data
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2794 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2795 (not (looking-at "\\<protected\\>"))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2796 )); end of `or'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2797 (goto-char (match-beginning 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2798 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2799 (setq nest-count (1- nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2800 (setq first nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2801
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2802 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2803 ((looking-at "new")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2804 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2805 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2806 (looking-at "is"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2807 (goto-char (match-beginning 0))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2808 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2809 ((and first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2810 (looking-at "begin"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2811 (setq nest-count 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2812 (setq flag t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2813 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2814 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2815 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2816 (setq first nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2817
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2818 ) ;; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2819
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2820 ;; check if declaration-start is really found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2821 (if (not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2822 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2823 (zerop nest-count)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2824 (not flag)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2825 (if (looking-at "is")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2826 (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
2827 (looking-at "declare\\|generic"))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2828 (if noerror nil
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
2829 (error "no matching proc/func/task/declare/package/protected"))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2830 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2831
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2832
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2833 (defun ada-goto-matching-start (&optional nest-level noerror gotothen)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2834 ;; Moves point to the beginning of a block-start. Which block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2835 ;; depends on the value of NEST-LEVEL, which defaults to zero. If
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836 ;; NOERROR is non-nil, it only returns nil if no matching start was
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2837 ;; found. If GOTOTHEN is non-nil, point moves to the 'then'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838 ;; following 'if'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2840 (found nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2841 (pos nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2848 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2849 (concat "\\<\\("
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2850 "end\\|loop\\|select\\|begin\\|case\\|do\\|"
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2851 "if\\|task\\|package\\|record\\|protected\\)\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2852 t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2853
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2854 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 ;; found block end => increase nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 ((looking-at "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2860 (setq nest-count (1+ nest-count)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2861 ;; found loop/select/record/case/if => check if it starts or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 ;; ends a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 ((looking-at "loop\\|select\\|record\\|case\\|if")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864 (setq pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 ;; check if keyword follows 'end'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 (ada-goto-previous-word)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2870 (if (looking-at "\\<end\\> *[^;]")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2871 ;; it ends a block => increase nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2872 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2873 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2874 (setq pos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2875 ;; it starts a block => decrease nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2876 (setq nest-count (1- nest-count))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2877 (goto-char pos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2878 ;; found package start => check if it really is a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2879 ((looking-at "package")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 (ada-search-ignore-string-comment "\\<is\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 ;; ignore it if it is only a declaration with 'new'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 (if (not (looking-at "\\<new\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885 (setq nest-count (1- nest-count)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 ;; found task start => check if it has a body
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887 ((looking-at "task")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891 ;; ignore it if it has no body
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892 (if (not (looking-at "\\<body\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893 (setq nest-count (1- nest-count)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2894 ;; all the other block starts
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2895 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2896 (setq nest-count (1- nest-count)))) ; end of 'cond'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2897
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2898 ;; match is found, if nest-depth is zero
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2899 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2900 (setq found (zerop nest-count))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2901
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2904 ;; match found => is there anything else to do ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2907 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2908 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2909 ;; found 'if' => skip to 'then', if it's on a separate line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2910 ;; and GOTOTHEN is non-nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2911 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2912 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2913 gotothen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2914 (looking-at "if")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2915 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2916 (ada-search-ignore-string-comment "\\<then\\>" nil nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2917 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2918 (looking-at "\\<then\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2919 (goto-char (match-beginning 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921 ;; found 'do' => skip back to 'accept'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2922 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2923 ((looking-at "do")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2924 (if (not (ada-search-ignore-string-comment "\\<accept\\>" t nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 (error "missing 'accept' in front of 'do'"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2927
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2928 (if noerror
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930 (error "no matching start")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2933 (defun ada-goto-matching-end (&optional nest-level noerror)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 ;; Moves point to the end of a block. Which block depends on the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2935 ;; value of NEST-LEVEL, which defaults to zero. If NOERROR is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 ;; non-nil, it only returns nil if found no matching start.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2938 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2939
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2940 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2941 ;; search forward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2942 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2943 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2944 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2945 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 (concat "\\<\\(end\\|loop\\|select\\|begin\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947 "if\\|task\\|package\\|record\\|do\\)\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2952 (backward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 ;; found block end => decrease nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955 ((looking-at "\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2956 (setq nest-count (1- nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2957 ;; skip the following keyword
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2958 (if (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959 (skip-chars-forward "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 (looking-at "\\<\\(loop\\|select\\|record\\|case\\|if\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962 (forward-word 1)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 ;; found package start => check if it really starts a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2964 ((looking-at "\\<package\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2965 (ada-search-ignore-string-comment "\\<is\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2966 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2967 ;; ignore and skip it if it is only a 'new' package
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2968 (if (not (looking-at "\\<new\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2970 (skip-chars-forward "new")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2971 ;; all the other block starts
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974 (forward-word 1))) ; end of 'cond'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2975
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976 ;; match is found, if nest-depth is zero
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 (setq found (zerop nest-count))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2980 (if (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981 (if noerror
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2982 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2983 (error "no matching end"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2984 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2985
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2986
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2987 (defun ada-forward-sexp-ignore-comment ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2988 ;; Skips one sexp forward, ignoring comments.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2989 (while (looking-at "[ \t\n]*--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2990 (skip-chars-forward "[ \t\n]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2991 (end-of-line))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2992 (forward-sexp 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2993
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2994
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2995 (defun ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2996 (search-re &optional backward limit paramlists)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2997 ;; Regexp-Search for SEARCH-RE, ignoring comments, strings and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2998 ;; parameter lists, if PARAMLISTS is nil. Returns a cons cell of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2999 ;; begin and end of match data or nil, if not found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3000 (let ((found nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3001 (begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3002 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3003 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3004 (search-func
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3005 (if backward 're-search-backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3006 're-search-forward)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3007
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3008 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3009 ;; search until found or end-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3010 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3011 (while (and (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3012 (funcall search-func search-re limit 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3013 (setq begin (match-beginning 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3014 (setq end (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3015
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3017 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3018 ;; found in comment => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3019 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3020 ((ada-in-comment-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3021 (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3023 (re-search-backward "--" nil 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3024 (goto-char (match-beginning 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3025 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3027 (beginning-of-line))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3028 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3029 ;; found in string => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3030 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3031 ((ada-in-string-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3032 (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3033 (progn
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3034 (re-search-backward "\"" nil 1) ; "\"\\|#" don't treat #
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3035 (goto-char (match-beginning 0))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3036 (re-search-forward "\"" nil 1))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3037 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3038 ;; found character constant => ignore it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3039 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3040 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3041 (setq pos (- (point) (if backward 1 2)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3042 (and (char-after pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3043 (= (char-after pos) ?')
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3044 (= (char-after (+ pos 2)) ?')))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3045 ())
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3046 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3047 ;; found a parameter-list but should ignore it => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3048 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3049 ((and (not paramlists)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3050 (ada-in-paramlist-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3051 (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3052 (ada-search-ignore-string-comment "(" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3053 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3054 ;; directly in front of a comment => skip it, if searching forward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3055 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 (looking-at "--"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 (if (not backward)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3062 (beginning-of-line))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3063 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3064 ;; found what we were looking for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3065 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3066 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3067 (setq found t)))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3068
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3069 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3070 (cons begin end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3071 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3072
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3073
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3074 (defun ada-search-but-not (search-re not-search-re &optional backward limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3075 ;; Searches SEARCH-RE, ignoring parts of NOT-SEARCH-RE, strings,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3076 ;; comments and parameter-lists.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3077 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3078 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3079 (begin-not nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3080 (begin-end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3081 (end-not nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3082 (ret-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3083 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3084
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3085 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3086 ;; search until found or end-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3087 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3088 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3089 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3090 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3091 (setq ret-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3092 (ada-search-ignore-string-comment search-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3093 backward limit))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3094 (if (consp ret-cons)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3095 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 (setq begin (car ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097 (setq end (cdr ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3098 t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3099 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3100
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3101 (if (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3102 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3103 ;; if no NO-SEARCH-RE was found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3104 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3105 (not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3106 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3107 (setq ret-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 (ada-search-ignore-string-comment not-search-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 backward nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3110 (if (consp ret-cons)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3111 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3112 (setq begin-not (car ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3113 (setq end-not (cdr ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3114 t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3115 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3116 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 ;; or this NO-SEARCH-RE is not a part of the SEARCH-RE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3118 ;; found before.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3119 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3120 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3121 (<= end-not begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3122 (>= begin-not end)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3123
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3124 (setq found t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3126 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3127 ;; not found the correct match => skip this match
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3128 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3129 (goto-char (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3130 begin
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3131 end)))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3132
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3133 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3134 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3135 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3136 (cons begin end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3137 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3138
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3139
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3140 (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
3141 ;; Moves point to the beginning of previous non-blank line,
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3142 ;; ignoring comments if IGNORE-COMMENT is non-nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3143 ;; It returns t if a matching line was found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3144 (let ((notfound t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3145 (newpoint nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3146
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3147 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3148 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3149 ;; backward one line, if there is one
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3150 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 (if (zerop (forward-line -1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3152 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3153 ;; there is some kind of previous line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3154 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3155 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3156 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3157 (setq newpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3158
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3159 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3160 ;; search until found or beginning-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3161 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3162 (while (and (setq notfound
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3163 (or (looking-at "[ \t]*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3164 (and (looking-at "[ \t]*--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3165 ignore-comment)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3166 (not (ada-in-limit-line-p)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3167 (forward-line -1)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3168 ;;(beginning-of-line)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169 (setq newpoint (point))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3170
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3171 )) ; end of if
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3172
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 ) ; end of save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3174
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3175 (if notfound nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3176 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3177 (goto-char newpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3178 t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3179
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3180
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3181 (defun ada-goto-next-nonblank-line ( &optional ignore-comment)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3182 ;; Moves point to next non-blank line,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3183 ;; ignoring comments if IGNORE-COMMENT is non-nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3184 ;; It returns t if a matching line was found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3185 (let ((notfound t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3186 (newpoint nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3187
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3188 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3189 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3190 ;; forward one line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3191 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3192 (if (zerop (forward-line 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3193 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3194 ;; there is some kind of previous line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 (setq newpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201 ;; search until found or end-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 (while (and (setq notfound
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 (or (looking-at "[ \t]*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (and (looking-at "[ \t]*--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 ignore-comment)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3207 (not (ada-in-limit-line-p)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3209 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3210 (setq newpoint (point))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3211
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3212 )) ; end of if
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3213
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3214 ) ; end of save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3215
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3216 (if notfound nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3217 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3218 (goto-char newpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3219 t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3220
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222 ;; ---- boolean functions for indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3223
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 (defun ada-in-decl-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3225 ;; Returns t if point is inside a declarative part.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3226 ;; Assumes point to be at the end of a statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3227 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3228 (ada-in-paramlist-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3229 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3230 (ada-goto-matching-decl-start t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3231
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3232
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3233 (defun ada-looking-at-semi-or ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234 ;; Returns t if looking-at an 'or' following a semicolon.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236 (and (looking-at "\\<or\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 (looking-at "\\<or\\>")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3241
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3243 (defun ada-looking-at-semi-private ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3244 ;; Returns t if looking-at an 'private' following a semicolon.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3245 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246 (and (looking-at "\\<private\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3248 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (looking-at "\\<private\\>")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3251
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3252
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3253 ;;; 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
3254 (defun ada-in-limit-line-p ()
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3255 ;; 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
3256 (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
3257 (save-excursion (end-of-line) (= (point-max) (point)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3258
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3260 (defun ada-in-comment-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3261 ;; 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
3262 (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
3263 (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
3264 (point))))
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3265
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3267 (defun ada-in-string-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3268 ;; Returns t if point is inside a string
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269 ;; (Taken from pascal-mode.el, modified by MH).
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3271 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3272 (nth 3 (parse-partial-sexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3273 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3274 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3275 (point)) (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 ;; check if 'string quote' is only a character constant
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3277 (progn
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3278 (re-search-backward "\"" nil t) ; `#' is not taken as a string delimiter
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3279 (not (= (char-after (1- (point))) ?'))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3280
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3281
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282 (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
3283 ;; 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
3284 (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
3285 (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
3286 (or ;; in-comment-p
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3287 (nth 4 parse-result)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3288 ;; in-string-p
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3289 (and
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3290 (nth 3 parse-result)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3291 ;; 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
3292 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3293 (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
3294 (not (= (char-after (1- (point))) ?'))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3295 ;; in-char-const-p
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3296 (ada-in-char-const-p))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3297
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3298
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3299 (defun ada-in-paramlist-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3300 ;; Returns t if point is inside a parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3301 ;; following 'function'/'procedure'/'package'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3302 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3304 (re-search-backward "(\\|)" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 ;; inside parentheses ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 (looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307 (backward-word 2)
13963
a62c62ac5102 (ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
3308 ;; right keyword before parenthesis ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3309 (looking-at (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3310 "procedure\\|function\\|body\\|package\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 "task\\|entry\\|accept\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 (re-search-forward ")\\|:" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3313 ;; at least one ':' inside the parentheses ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3314 (not (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 (looking-at ":"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3316
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3317
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3318 ;; not really a boolean function ...
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3319 (defun ada-in-open-paren-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3320 ;; If point is somewhere behind an open parenthesis not yet closed,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3321 ;; it returns the column # of the first non-ws behind this open
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3322 ;; parenthesis, otherwise nil."
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3323 (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
3324 (point-min)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3325 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3326 (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
3327 (beginning-of-line)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3328 (point))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3329 parse-result
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3330 (col nil))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3331 (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
3332 (if (nth 1 parse-result)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3333 (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3334 (goto-char (1+ (nth 1 parse-result)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3335 (if (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3336 (re-search-forward "[^ \t]" nil 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3337 (backward-char 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3338 (and
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3339 (not (looking-at "\n"))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3340 (setq col (current-column))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3341 col
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3342 (current-column)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3343 nil)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3344
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3345
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3346
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3347 ;;;----------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3348 ;;; Behaviour Of TAB Key ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 ;;;----------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 (defun ada-tab ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3352 "Do indenting or tabbing according to `ada-tab-policy'."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3354 (cond ((eq ada-tab-policy 'indent-and-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3355 ;; ada-indent-and-tab
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 ((eq ada-tab-policy 'indent-auto) (ada-indent-current))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3358 ((eq ada-tab-policy 'gei) (ada-tab-gei))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359 ((eq ada-tab-policy 'indent-af) (af-indent-line)) ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3360 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3361 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3362
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3363
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3364 (defun ada-untab (arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 "Delete leading indenting according to `ada-tab-policy'."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367 (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3368 ((eq ada-tab-policy 'indent-af) (backward-delete-char-untabify ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3369 (prefix-numeric-value arg) ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3370 arg)) ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3371 ((eq ada-tab-policy 'indent-auto) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3374
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3375
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3376 (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
3377 "Ada mode version of the indent-line-function."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3378 (interactive "*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379 (let ((starting-point (point-marker)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3380 (ada-beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3381 (ada-tab)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3382 (if (< (point) starting-point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3383 (goto-char starting-point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3384 (set-marker starting-point nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3385 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3386
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3387
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3388 (defun ada-tab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3389 "Indent current line to next tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3390 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3391 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3392 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3393 (insert-char ? ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3394 (if (save-excursion (= (point) (progn (beginning-of-line) (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3395 (forward-char ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3396
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3397
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3398 (defun ada-untab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3399 "indent current line to previous tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3400 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3401 (let ((bol (save-excursion (progn (beginning-of-line) (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3402 (eol (save-excursion (progn (end-of-line) (point)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3403 (indent-rigidly bol eol (- 0 ada-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3404
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3405
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3407 ;;;---------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3408 ;;; Miscellaneous ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3409 ;;;---------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3410
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3411 (defun ada-remove-trailing-spaces ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3412 "remove trailing spaces in the whole buffer."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3413 (interactive)
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3414 (save-match-data
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3415 (save-excursion
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3416 (save-restriction
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3417 (widen)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3418 (goto-char (point-min))
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3419 (while (re-search-forward "[ \t]+$" (point-max) t)
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3420 (replace-match "" nil nil))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3421
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3422
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3423 (defun ada-untabify-buffer ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3424 ;; change all tabs to spaces
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3425 (save-excursion
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3426 (untabify (point-min) (point-max))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3427 nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3428
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 (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
3431 "delete `comment-start' at the beginning of a line in the region."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432 (interactive "r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 (comment-region beg end -1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436 ;; define a function to support find-file.el if loaded
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3437 (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
3438 "Find other file in other window using `ff-find-other-file'."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3439 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3440 (and (fboundp 'ff-find-other-file)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3441 (ff-find-other-file t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3442
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3443 ;; 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
3444 (defun ada-gnat-style ()
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3445 "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
3446 (interactive)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3447 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3448 (goto-char (point-min))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3449 (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
3450 (replace-match "-- \\1"))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3451 (goto-char (point-min))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3452 (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
3453 (replace-match " ("))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3454 (goto-char (point-min))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3455 (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
3456 (replace-match ", "))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3457 ))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3458
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3459
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3460
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3461 ;;;-------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3462 ;;; Moving To Procedures/Packages ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3463 ;;;-------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3464
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3465 (defun ada-next-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3466 "Moves point to next procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3467 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3468 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469 (if (re-search-forward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3470 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3471 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3473 (defun ada-previous-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3474 "Moves point to previous procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3475 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3476 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3477 (if (re-search-backward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3478 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3479 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3480
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3481 (defun ada-next-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3482 "Moves point to next package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3483 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3484 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3485 (if (re-search-forward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3486 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3487 (error "No more packages")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3488
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3489 (defun ada-previous-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 "Moves point to previous package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3491 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 (if (re-search-backward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495 (error "No more packages")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3496
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 ;;;-----------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3499 ;;; define keymap for Ada
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3500 ;;;-----------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3501
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3502 (if (not ada-mode-map)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3503 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504 (setq ada-mode-map (make-sparse-keymap))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506 ;; Indentation and Formatting
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507 (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 (define-key ada-mode-map "\t" 'ada-tab)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3509 (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
3510 (if (ada-xemacs)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3511 (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
3512 (define-key ada-mode-map [S-tab] 'ada-untab))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3513 (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3514 (define-key ada-mode-map "\C-c\C-p" 'ada-call-pretty-printer)
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3515 ;;; We don't want to make meta-characters case-specific.
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3516 ;;; (define-key ada-mode-map "\M-Q" 'ada-fill-comment-paragraph-justify)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3517 (define-key ada-mode-map "\M-\C-q" 'ada-fill-comment-paragraph-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3518
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3519 ;; Movement
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3520 ;;; 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
3521 ;;; (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
3522 ;;; (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
3523 (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
3524 (define-key ada-mode-map "\M-\C-a" 'ada-previous-procedure)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3525 (define-key ada-mode-map "\C-c\C-a" 'ada-move-to-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3526 (define-key ada-mode-map "\C-c\C-e" 'ada-move-to-end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3527
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 ;; Compilation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529 (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
3530 (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
3531 (define-key ada-mode-map "\C-c\C-m" 'ada-make-local)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 ;; Casing
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534 (define-key ada-mode-map "\C-c\C-r" 'ada-adjust-case-region)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535 (define-key ada-mode-map "\C-c\C-b" 'ada-adjust-case-buffer)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 (define-key ada-mode-map "\177" 'backward-delete-char-untabify)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 ;; Use predefined function of emacs19 for comments (RE)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3540 (define-key ada-mode-map "\C-c;" 'comment-region)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3541 (define-key ada-mode-map "\C-c:" 'ada-uncomment-region)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3542
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 ;; Change basic functionality
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3544
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3545 ;; `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
3546 ;; 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
3547 ;; 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
3548 ;; 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
3549 ;; following three functions, please tell me. RE
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3550 (mapcar (function (lambda (pair)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3551 (substitute-key-definition (car pair) (cdr pair)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3552 ada-mode-map)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3553 '((beginning-of-line . ada-beginning-of-line)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3554 (end-of-line . ada-end-of-line)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3555 (forward-to-indentation . ada-forward-to-indentation)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3556 ))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3557 ;; else Emacs
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3558 ;;(mapcar (lambda (pair)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3559 ;; (substitute-key-definition (car pair) (cdr pair)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3560 ;; ada-mode-map global-map))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3561
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3563
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3565 ;;;-------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3566 ;;; define menu 'Ada'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3567 ;;;-------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3569 (require 'easymenu)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3570
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3571 (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
3572 "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
3573 (easy-menu-define ada-mode-menu ada-mode-map "Menu keymap for Ada mode."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574 '("Ada"
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3575 ["Next Package" ada-next-package t]
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3576 ["Previous Package" ada-previous-package t]
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3577 ["Next Procedure" ada-next-procedure t]
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3578 ["Previous Procedure" ada-previous-procedure t]
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3579 ["Goto Start" ada-move-to-start t]
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3580 ["Goto End" ada-move-to-end t]
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3581 ["------------------" nil nil]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3582 ["Indent Current Line (TAB)"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3583 ada-indent-current-function t]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3584 ["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
3585 ["Format Parameter List" ada-format-paramlist t]
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3586 ["Pretty Print Buffer" ada-call-pretty-printer t]
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3587 ["------------" nil nil]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3588 ["Fill Comment Paragraph"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3589 ada-fill-comment-paragraph t]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3590 ["Justify Comment Paragraph"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3591 ada-fill-comment-paragraph-justify t]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3592 ["Postfix Comment Paragraph"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3593 ada-fill-comment-paragraph-postfix t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3594 ["------------" nil nil]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3595 ["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
3596 ["Adjust Case Buffer" ada-adjust-case-buffer t]
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 ["----------" nil nil]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3598 ["Comment Region" comment-region t]
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3599 ["Uncomment Region" ada-uncomment-region t]
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600 ["----------------" nil nil]
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3601 ["Global Make" compile (fboundp 'compile)]
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3602 ["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
3603 ["Check Syntax" ada-check-syntax t]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3604 ["Next Error" next-error (fboundp 'next-error)]
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 ["---------------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606 ["Index" imenu (fboundp 'imenu)]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3607 ["--------------" nil nil]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3608 ["Other File Other Window" ada-ff-other-window
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3609 (fboundp 'ff-find-other-file)]
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3610 ["Other File" ff-find-other-file
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3611 (fboundp 'ff-find-other-file)]))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3612 (if (ada-xemacs) (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3613 (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
3614 (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
3615
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3616
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618 ;;;-------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619 ;;; Define Some Support Functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 ;;;-------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622 (defun ada-beginning-of-line (&optional arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 ((eq ada-tab-policy 'indent-af) (af-beginning-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 (t (beginning-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3629 (defun ada-end-of-line (&optional arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3630 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 ((eq ada-tab-policy 'indent-af) (af-end-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633 (t (end-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636 (defun ada-current-column ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3637 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3638 ((eq ada-tab-policy 'indent-af) (af-current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639 (t (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3642 (defun ada-forward-to-indentation (&optional arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3643 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3645 ((eq ada-tab-policy 'indent-af) (af-forward-to-indentation arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3646 (t (forward-to-indentation arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3648
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3649 ;;;---------------------------------------------------
17929
12851b631f87 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17914
diff changeset
3650 ;;; support for find-file.el
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3653
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3654 ;;;###autoload
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3655 (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
3656 "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
3657 ;; this is done simply by calling `gnatkr', when we work with GNAT. It
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3658 ;; must be a more complex function in other compiler environments.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659 (interactive "s")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660 (let (krunch-buf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 (setq krunch-buf (generate-new-buffer "*gkrunch*"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3662 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3663 (set-buffer krunch-buf)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3664 ;; 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
3665 (call-process "gnatkr" nil krunch-buf nil
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3666 adaname ada-krunch-args)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667 ;; fetch output of that process
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3668 (setq adaname (buffer-substring
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 (point-min)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3670 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3671 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3672 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3674 (kill-buffer krunch-buf)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675 (setq adaname adaname) ;; can I avoid this statement?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3676 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3677
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3678
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3679 ;;; 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
3680 (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
3681 "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
3682 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
3683
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3684 (setq ff-function-name nil)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3685
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3686 (save-excursion
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3687 (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
3688 (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
3689 (match-end 0)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3690 ; 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
3691 (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
3692 (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
3693 (match-end 0)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3694 ))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3695
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3696
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3697 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3698 ;;; support for font-lock
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3699 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3700
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3701 ;; 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
3702 ;; 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
3703 ;; 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
3704 ;; 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
3705 ;; 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
3706
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3707 (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
3708 ;; 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
3709 '(("\\(\'\\).\\(\'\\)" (1 (7 . ?\')) (2 (7 . ?\')))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 (defconst ada-font-lock-keywords-1
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3712 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3713 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3714 ;; 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
3715 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3716 (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
3717 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3718 ;; 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
3719 ;; pragma, procedure, task (body) plus name.
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3720 (list (concat
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3721 "\\<\\("
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3722 "accept\\|"
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3723 "entry\\|"
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3724 "function\\|"
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3725 "package[ \t]+body\\|"
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3726 "package\\|"
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3727 "pragma\\|"
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3728 "procedure\\|"
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3729 "protected[ \t]+body\\|"
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3730 "protected[ \t]+type\\|"
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3731 "protected\\|"
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3732 ;; "p\\(\\(ackage\\|rotected\\)\\(\\|[ \t]+\\(body\\|type\\)\\)\
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3733 ;;\\|r\\(agma\\|ocedure\\)\\)\\|"
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3734 "task[ \t]+body\\|"
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3735 "task[ \t]+type\\|"
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3736 "task"
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3737 ;; "task\\(\\|[ \t]+body\\)"
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3738 "\\)\\>[ \t]*"
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3739 "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3740 '(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
3741 "Subdued level highlighting for Ada mode.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3742
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3743 (defconst ada-font-lock-keywords-2
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3744 (append ada-font-lock-keywords-1
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3745 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3746 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3747 ;; Main keywords, except those treated specially below.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3748 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3749 ; ("abort" "abs" "abstract" "accept" "access" "aliased" "all"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3750 ; "and" "array" "at" "begin" "case" "declare" "delay" "delta"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3751 ; "digits" "do" "else" "elsif" "entry" "exception" "exit" "for"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3752 ; "generic" "if" "in" "is" "limited" "loop" "mod" "not"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3753 ; "null" "or" "others" "private" "protected"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3754 ; "range" "record" "rem" "renames" "requeue" "return" "reverse"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3755 ; "select" "separate" "tagged" "task" "terminate" "then" "until"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3756 ; "while" "xor")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757 "a\\(b\\(ort\\|s\\(\\|tract\\)\\)\\|cce\\(pt\\|ss\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3758 "l\\(iased\\|l\\)\\|nd\\|rray\\|t\\)\\|begin\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3759 "d\\(e\\(clare\\|l\\(ay\\|ta\\)\\)\\|igits\\|o\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3760 "e\\(ls\\(e\\|if\\)\\|ntry\\|x\\(ception\\|it\\)\\)\\|for\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3761 "generic\\|i[fns]\\|l\\(imited\\|oop\\)\\|mod\\|n\\(ot\\|ull\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 "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
3763 "r\\(a\\(ise\\|nge\\)\\|e\\(cord\\|m\\|names\\|queue\\|turn\\|verse\\)\\)\\|"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 "se\\(lect\\|parate\\)\\|"
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3765 "t\\(agged\\|erminate\\|hen\\)\\|until\\|" ; task removed
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3766 "wh\\(ile\\|en\\)\\|xor" ; "when" added
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3767 "\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3768 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3769 ;; 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
3770 '("\\<\\(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
3771 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3773 ;; Variable name plus optional keywords followed by a type name. Slow.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3774 ; (list (concat "\\<\\(\\sw+\\)\\>[ \t]*:?[ \t]*"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3775 ; "\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)?[ \t]*"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3776 ; "\\(\\sw+\\)?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3777 ; '(1 font-lock-variable-name-face)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3778 ; '(2 font-lock-keyword-face nil t) '(3 font-lock-type-face nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3779 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3780 ;; Optional keywords followed by a type name.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3781 (list (concat ; ":[ \t]*"
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3782 "\\<\\(access\\|constant\\|in[ \t]+out\\|in\\|out\\)\\>"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3783 "[ \t]*"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3784 "\\(\\sw+\\)?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3785 '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3786 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3787 ;; Keywords followed by a type or function name.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3788 (list (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3789 "new\\|of\\|subtype\\|type"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3790 "\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*\\((\\)?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3791 '(1 font-lock-keyword-face)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3792 '(2 (if (match-beginning 4)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3793 font-lock-function-name-face
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3794 font-lock-type-face) nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3795 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3796 ;; 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
3797 (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)\\>" ; "when" removed
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3798 ; "[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?") ; RE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3799 "[ \t]*\\([a-zA-Z0-9_\\.\\|, ]+\\)\\W")
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20459
diff changeset
3800 '(1 font-lock-keyword-face) '(2 font-lock-constant-face nil t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3801 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3802 ;; Goto tags.
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 20459
diff changeset
3803 '("<<\\(\\sw+\\)>>" 1 font-lock-constant-face)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3804 ))
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3805 "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
3806
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3807 (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
3808 "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
3809
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3810
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3811 ;; 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
3812 (if (ada-xemacs)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3813 (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
3814 '(ada-font-lock-keywords
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3815 nil t ((?\_ . "w")(?\. . "w")) beginning-of-line)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3816
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3817 ;;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3818 ;;; support for outline
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3819 ;;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3820
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3821 ;; used by outline-minor-mode
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3822 (defun ada-outline-level ()
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3823 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3824 (skip-chars-forward "\t ")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3825 (current-column)))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3826
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3827 ;;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3828 ;;; generate body
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3829 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3830 (defun ada-gen-comment-until-proc ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3831 ;; comment until spec of a procedure or a function.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3832 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 (set-mark-command (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834 (if (re-search-forward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3835 (progn (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3836 (comment-region (mark) (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 (error "No more functions/procedures")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3838
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3840 (defun ada-gen-treat-proc (match)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3841 ;; 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
3842 ;; 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
3843 ;; last search for ada-procedure-start-regexp.
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3844 (goto-char (car match))
13160
1b2a4a45f089 (ada-gen-treat-proc): Bind `procname' and `functype'.
Erik Naggum <erik@naggum.no>
parents: 12702
diff changeset
3845 (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
3846 (cond
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3847 ((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
3848 (setq func-found (looking-at "^[ \t]*function")))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3849 ;; treat it as a proc/func
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3850 (forward-word 2)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3851 (forward-word -1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3852 (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
3853
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3854 ;; goto end of procname
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3855 (goto-char (cdr match))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3856
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3857 ;; skip over parameterlist
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3858 (forward-sexp)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3859 ;; 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
3860 (if func-found
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3861 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3862 (forward-word 1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3863 (skip-chars-forward " \t\n")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3864 (setq functype (buffer-substring (point)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3865 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3866 (skip-chars-forward
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3867 "a-zA-Z0-9_\.")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3868 (point))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3869 ;; look for next non WS
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3870 (cond
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3871 ((looking-at "[ \t]*;")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3872 (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
3873 (ada-indent-newline-indent)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3874 (insert " is")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3875 (ada-indent-newline-indent)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3876 (if func-found
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3877 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3878 (insert "Result : ")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3879 (insert functype)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3880 (insert ";")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3881 (ada-indent-newline-indent)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3882 (insert "begin -- ")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3883 (insert procname)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3884 (ada-indent-newline-indent)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3885 (insert "null;")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3886 (ada-indent-newline-indent)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3887 (if func-found
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3888 (progn
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3889 (insert "return Result;")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3890 (ada-indent-newline-indent)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3891 (insert "end ")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3892 (insert procname)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3893 (insert ";")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3894 (ada-indent-newline-indent)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3895 )
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3896 ;; else
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3897 ((looking-at "[ \t\n]*is")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3898 ;; do nothing
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3899 )
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3900 ((looking-at "[ \t\n]*rename")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3901 ;; do nothing
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3902 )
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3903 (t
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3904 (message "unknown syntax")))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3905 ))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3906
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3907
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3908 (defun ada-make-body ()
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3909 "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
3910 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
3911 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
3912
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3913 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
3914 (interactive)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3915 (delete-region (point-min) (point-max))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3916 (insert-buffer (car (cdr (buffer-list))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3917 (ada-mode)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3918
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3919 (let (found)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3920 (if (setq found
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3921 (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
3922 (progn (goto-char (cdr found))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3923 (insert " body")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3924 ;; (forward-line -1)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3925 ;;(comment-region (point-min) (point))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3926 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3927 (error "No package"))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3928
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3929 ;; (comment-until-proc)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3930 ;; does not work correctly
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3931 ;; must be done by hand
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3932
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3933 (while (setq found
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3934 (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
3935 (ada-gen-treat-proc found))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3936
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3937
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3938 ;;; provide ourself
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3939
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3940 (provide 'ada-mode)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3941
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3942 ;;; ada-mode.el ends here