annotate lisp/modes/ada-mode.el @ 44:8d2a9b52c682 r19-15prefinal

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