annotate lisp/modes/ada-mode.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; ada-mode.el - An Emacs major-mode for editing Ada source.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; 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
24 ;;; and Ada 95 source code under Emacs-19. It contains completely new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; indenting code and support for code browsing (see ada-xref).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Synched up with: FSF 19.29.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; USAGE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; =====
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Emacs should enter ada-mode when you load an ada source (*.ad[abs]).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; When you have entered ada-mode, you may get more info by pressing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; C-h m. You may also get online help describing various functions by:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; C-h d <Name of function you want described>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; HISTORY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; =======
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; The first Ada mode for GNU Emacs was written by V. Broman in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; 1985. He based his work on the already existing Modula-2 mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; 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
43 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; Lynn Slater wrote an extensive Ada mode in 1989. It consisted of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; several files with support for dired commands and other nice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; things. It is currently available from the PAL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; (wuarchive.wustl.edu:/languages/ada) as ada-mode-1.06a.tar.Z.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; The probably very first Ada mode (called electric-ada.el) was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; written by Steven D. Litvintchouk and Steven M. Rosen for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; Gosling Emacs. L. Slater based his development on ada.el and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; electric-ada.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; The current Ada mode is a complete rewrite by M. Heritsch and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; R. Ebert. Some ideas from the ada-mode mailing list have been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; added. Some of the functionality of L. Slater's mode has not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; (yet) been recoded in this new mode. Perhaps you prefer sticking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; to his version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; KNOWN BUGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; ==========
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; In the presence of comments and/or incorrect syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; ada-format-paramlist produces weird results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; Indenting of some tasking constructs is still buggy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; -------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; For tagged types the problem comes from the keyword abstract:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; type T2 is abstract tagged record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; X : Integer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; Y : Float;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; end record;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; -------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; In Emacs FSF 19.28, ada-mode will correctly indent comments at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; very beginning of the buffer (_before_ any code) when I go M-; but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;; when I press TAB I'd expect the comments to be placed at the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; of the line, just as the first line of _code_ would be indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; This does not happen but the comment stays put :-( I end up going
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; M-; C-a M-\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; -------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; package Test is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; -- 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
86 ;;; -- in another 3 space instead of heading out to the "(". If I hit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; -- tab or return it reindents the line correctly but does not initially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; type Wait_Return is (Read_Success, Read_Timeout, Wait_Timeout,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; Nothing_To_Wait_For_In_Wait_List);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; -- The following line will be wrongly reindented after typing it in after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; -- the initial indent for the line was correct after type return after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; -- this line. Subsequent lines will show the same problem.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; Unused: constant Queue_ID := 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; -------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; -- If I do the following I get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; -- "no matching procedure/function/task/declare/package"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; -- when I do return (I reverse the mappings of ^j and ^m) after "private".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; package Package1 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; package Package1_1 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; type The_Type is private;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; private
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; -------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; -- But what about this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; package G is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; type T1 is new Integer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; type T2 is new Integer; --< incorrect, correct if subtype
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; package H is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; type T3 is new Integer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; type --< Indentation is incorrect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; -------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; CREDITS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; =======
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; Many thanks to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; Philippe Warroquiers (PW) <philippe@cfmu.eurocontrol.be> in particular,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;; woodruff@stc.llnl.gov (John Woodruff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; jj@ddci.dk (Jesper Joergensen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; gse@ocsystems.com (Scott Evans)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; comar@LANG8.CS.NYU.EDU (Cyrille Comar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; and others for their valuable hints.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;;--------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; USER OPTIONS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;;--------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; ---- configure indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defvar ada-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 "*Defines the size of Ada indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defvar ada-broken-indent 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 "*# of columns to indent the continuation of a broken line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defvar ada-label-indent -4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "*# of columns to indent a label.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defvar ada-stmt-end-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 "*# of columns to indent a statement end keyword in a separate line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 Examples are 'is', 'loop', 'record', ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defvar ada-when-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 "*Defines the indentation for 'when' relative to 'exception' or 'case'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defvar ada-indent-record-rel-type 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "*Defines the indentation for 'record' relative to 'type' or 'use'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defvar ada-indent-comment-as-code t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "*If non-nil, comment-lines get indented as ada-code.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defvar ada-indent-is-separate t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "*If non-nil, 'is separate' or 'is abstract' on a separate line are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 indented.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defvar ada-indent-to-open-paren t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 "*If non-nil, following lines get indented according to the innermost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 open parenthesis.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defvar ada-search-paren-char-count-limit 3000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "*Search that many characters for an open parenthesis.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; ---- other user options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defvar ada-tab-policy 'indent-auto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "*Control behaviour of the TAB key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 Must be one of 'indent-rigidly, 'indent-auto, 'gei, 'indent-af or 'always-tab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 'indent-rigidly : always adds ada-indent blanks at the beginning of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 'indent-auto : use indentation functions in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 'gei : use David Kågedal's Generic Indentation Engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 'indent-af : use Gary E. Barnes' ada-format.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 'always-tab : do indent-relative.")
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-move-to-declaration nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "*If non-nil, ada-move-to-start moves point to the subprog-declaration,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 not to 'begin'.")
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-spec-suffix ".ads"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "*Suffix of Ada specification files.")
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-body-suffix ".adb"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 "*Suffix of Ada body files.")
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-language-version 'ada95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 "*Do we program in 'ada83 or 'ada95?")
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-case-keyword 'downcase-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "*downcase-word, upcase-word, ada-loose-case-word or capitalize-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 to adjust ada keywords case.")
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-case-identifier 'ada-loose-case-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "*downcase-word, upcase-word, ada-loose-case-word or capitalize-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 to adjust ada identifier case.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (defvar ada-case-attribute 'capitalize-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 "*downcase-word, upcase-word, ada-loose-case-word or capitalize-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 to adjust ada identifier case.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (defvar ada-auto-case t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 "*Non-nil automatically changes casing of preceeding word while typing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 Casing is done according to ada-case-keyword and ada-case-identifier.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defvar ada-clean-buffer-before-saving nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "*If non-nil, remove-trailing-spaces and untabify buffer before saving.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defvar ada-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "*List of functions to call when Ada Mode is invoked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 This is a good place to add Ada environment specific bindings.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defvar ada-external-pretty-print-program "aimap"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "*External pretty printer to call from within Ada Mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defvar ada-tmp-directory "/tmp/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "*Directory to store the temporary file for the Ada pretty printer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defvar ada-fill-comment-prefix "-- "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "*This is inserted in the first columns when filling a comment paragraph.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defvar ada-fill-comment-postfix " --"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 "*This is inserted at the end of each line when filling a comment paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 with ada-fill-comment-paragraph postfix.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defvar ada-krunch-args "0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 "*Argument of gnatk8, a string containing the max number of characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 Set to 0, if you dont use crunched filenames.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; ---- end of user configurable variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (defvar ada-mode-abbrev-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 "Abbrev table used in Ada mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (define-abbrev-table 'ada-mode-abbrev-table ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defvar ada-mode-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Local keymap used for ada-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (defvar ada-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "Syntax table to be used for editing Ada source code.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defvar ada-mode-symbol-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "Syntax table for Ada, where `_' is a word constituent.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defconst ada-83-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "\\<\\(abort\\|abs\\|accept\\|access\\|all\\|and\\|array\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 at\\|begin\\|body\\|case\\|constant\\|declare\\|delay\\|delta\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 digits\\|do\\|else\\|elsif\\|end\\|entry\\|exception\\|exit\\|for\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 function\\|generic\\|goto\\|if\\|in\\|is\\|limited\\|loop\\|mod\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 new\\|not\\|null\\|of\\|or\\|others\\|out\\|package\\|pragma\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 private\\|procedure\\|raise\\|range\\|record\\|rem\\|renames\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 return\\|reverse\\|select\\|separate\\|subtype\\|task\\|terminate\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 then\\|type\\|use\\|when\\|while\\|with\\|xor\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "regular expression for looking at Ada83 keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defconst ada-95-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "\\<\\(abort\\|abs\\|abstract\\|accept\\|access\\|aliased\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 all\\|and\\|array\\|at\\|begin\\|body\\|case\\|constant\\|declare\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 delay\\|delta\\|digits\\|do\\|else\\|elsif\\|end\\|entry\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 exception\\|exit\\|for\\|function\\|generic\\|goto\\|if\\|in\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 is\\|limited\\|loop\\|mod\\|new\\|not\\|null\\|of\\|or\\|others\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 out\\|package\\|pragma\\|private\\|procedure\\|protected\\|raise\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 range\\|record\\|rem\\|renames\\|requeue\\|return\\|reverse\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 select\\|separate\\|subtype\\|tagged\\|task\\|terminate\\|then\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 type\\|until\\|use\\|when\\|while\\|with\\|xor\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "regular expression for looking at Ada95 keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (defvar ada-keywords ada-95-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "regular expression for looking at Ada keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (defvar ada-ret-binding nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "Variable to save key binding of RET when casing is activated.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (defvar ada-lfd-binding nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 "Variable to save key binding of LFD when casing is activated.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;; ---- Regexps to find procedures/functions/packages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defconst ada-ident-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "[a-zA-Z0-9_\\.]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "Regexp matching Ada identifiers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defvar ada-procedure-start-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\([a-zA-Z0-9_\\.]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "Regexp used to find Ada procedures/functions.")
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-package-start-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "^[ \t]*\\(package\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "Regexp used to find Ada packages")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;;; ---- regexps for indentation functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defvar ada-block-start-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "\\<\\(begin\\|select\\|declare\\|private\\|or\\|generic\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 exception\\|loop\\|else\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 \\(\\(limited\\|abstract\\|tagged\\)[ \t]+\\)*record\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 "Regexp for keywords starting ada-blocks.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defvar ada-end-stmt-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "\\(;\\|=>\\|^[ \t]*separate[ \t]+([a-zA-Z0-9_\\.]+)\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 \\<\\(begin\\|else\\|record\\|loop\\|select\\|do\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ^[ \t]*package[ \ta-zA-Z0-9_\\.]+is\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ^[ \t]*exception\\|declare\\|generic\\|private\\)\\>\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "Regexp of possible ends for a non-broken statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 'end' means that there has to start a new statement after these.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defvar ada-loop-start-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "\\<\\(for\\|while\\|loop\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 "Regexp for the start of a loop.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (defvar ada-subprog-start-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 "\\<\\(procedure\\|protected\\|package[ \t]+body\\|function\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 task\\|accept\\|entry\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "Regexp for the start of a subprogram.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;;;-------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;;; functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;;;-------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defun ada-xemacs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (or (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (string-match "XEmacs" emacs-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (defun ada-create-syntax-table ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 "Create the syntax table for ada-mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; There are two different syntax-tables. The standard one declares
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; `_' a symbol constituent, in the second one, it is a word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; constituent. For some search and replacing routines we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; temporarily switch between the two.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq ada-mode-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (set-syntax-table ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; define string brackets (% is alternative string bracket)
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
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
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 (modify-syntax-entry ?* "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (modify-syntax-entry ?/ "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (modify-syntax-entry ?= "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (modify-syntax-entry ?< "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (modify-syntax-entry ?> "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (modify-syntax-entry ?$ "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (modify-syntax-entry ?\[ "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (modify-syntax-entry ?\] "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (modify-syntax-entry ?\{ "." ada-mode-syntax-table)
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 (modify-syntax-entry ?. "." ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (modify-syntax-entry ?\\ "." ada-mode-syntax-table)
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; a single hyphen is punctuation, but a double hyphen starts a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (modify-syntax-entry ?- ". 12" ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; and \f and \n end a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (modify-syntax-entry ?\f "> " ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (modify-syntax-entry ?\n "> " ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; define what belongs in ada symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (modify-syntax-entry ?_ "_" ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;; define parentheses to match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (modify-syntax-entry ?\( "()" ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (modify-syntax-entry ?\) ")(" ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (setq ada-mode-symbol-syntax-table (copy-syntax-table ada-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (modify-syntax-entry ?_ "w" ada-mode-symbol-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defun ada-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "Ada Mode is the major mode for editing Ada code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 Bindings are as follows: (Note: 'LFD' is control-j.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 Indent line '\\[ada-tab]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 Indent line, insert newline and indent the new line. '\\[newline-and-indent]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 Re-format the parameter-list point is in '\\[ada-format-paramlist]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 Indent all lines in region '\\[ada-indent-region]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 Call external pretty printer program '\\[ada-call-pretty-printer]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 Adjust case of identifiers and keywords in region '\\[ada-adjust-case-region]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 Adjust case of identifiers and keywords in buffer '\\[ada-adjust-case-buffer]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 Call EXTERNAL pretty printer (if you have one) '\\[ada-call-pretty-printer]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 Fill comment paragraph '\\[ada-fill-comment-paragraph]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 Fill comment paragraph and justify each line '\\[ada-fill-comment-paragraph-justify]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 Fill comment paragraph, justify and append postfix '\\[ada-fill-comment-paragraph-postfix]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 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
404 Next package '\\[ada-next-package]' Previous package '\\[ada-previous-package]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 Goto matching start of current 'end ...;' '\\[ada-move-to-start]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 Goto end of current block '\\[ada-move-to-end]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 Comments are handled using standard GNU Emacs conventions, including:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 Start a comment '\\[indent-for-comment]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 Comment region '\\[comment-region]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 Uncomment region '\\[ada-uncomment-region]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 Continue comment on next line '\\[indent-new-comment-line]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 If you use imenu.el:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 Display index-menu of functions & procedures '\\[imenu]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 If you use find-file.el:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 Switch to other file (Body <-> Spec) '\\[ff-find-other-file]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 or '\\[ff-mouse-find-other-file]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 Switch to other file in other window '\\[ada-ff-other-window]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 or '\\[ff-mouse-find-other-file-other-window]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 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
424 with body stubs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 If you use ada-xref.el:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 Goto declaration: '\\[ada-point-and-xref]' on the identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 or '\\[ada-goto-declaration]' with point on the identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 Complete identifier: '\\[ada-complete-identifier]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Execute Gnatf: '\\[ada-gnatf-current]'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (setq require-final-newline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (make-local-variable 'comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq comment-start "-- ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;; comment end must be set because it may hold a wrong value if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;; this buffer had been in another mode before. RE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (make-local-variable 'comment-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq comment-end "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (make-local-variable 'comment-start-skip) ;; used by autofill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (setq comment-start-skip "--+[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (make-local-variable 'indent-line-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (setq indent-line-function 'ada-indent-current-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (make-local-variable 'fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (setq fill-column 75)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (make-local-variable 'comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq comment-column 40)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (make-local-variable 'parse-sexp-ignore-comments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (setq parse-sexp-ignore-comments t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (make-local-variable 'case-fold-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (setq case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (make-local-variable 'fill-paragraph-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq fill-paragraph-function 'ada-fill-comment-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (setq major-mode 'ada-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (setq mode-name "Ada")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (setq blink-matching-paren t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (use-local-map ada-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if ada-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (set-syntax-table ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (ada-create-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (if ada-clean-buffer-before-saving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; remove all spaces at the end of lines in the whole buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (add-hook 'local-write-file-hooks 'ada-remove-trailing-spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; convert all tabs to the correct number of spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (add-hook 'local-write-file-hooks 'ada-untabify-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;; add menu 'Ada' to the menu bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (ada-add-ada-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (run-hooks 'ada-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; the following has to be done after running the ada-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; because users might want to set the values of these variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; inside the hook (MH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (cond ((eq ada-language-version 'ada83)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (setq ada-keywords ada-83-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ((eq ada-language-version 'ada95)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setq ada-keywords ada-95-keywords)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (if ada-auto-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (ada-activate-keys-for-case)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;;;--------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;;; Fill Comment Paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;;;--------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defun ada-fill-comment-paragraph-justify ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 "Fills current comment paragraph and justifies each line as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (ada-fill-comment-paragraph t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (defun ada-fill-comment-paragraph-postfix ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "Fills current comment paragraph and justifies each line as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 Prompts for a postfix to be appended to each line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (ada-fill-comment-paragraph t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defun ada-fill-comment-paragraph (&optional justify postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 "Fills the current comment paragraph.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 If JUSTIFY is non-nil, each line is justified as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 If POSTFIX and JUSTIFY are non-nil, ada-fill-comment-postfix is appended
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 to each filled and justified line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 If ada-indent-comment-as code is non-nil, the paragraph is idented."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (let ((opos (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (end-2 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (indent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (ada-fill-comment-old-postfix "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (fill-prefix nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; check if inside comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (if (not (ada-in-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (error "not inside comment"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;; prompt for postfix if wanted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (if (and justify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (setq ada-fill-comment-postfix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (read-from-minibuffer "enter new postfix string: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ada-fill-comment-postfix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;; prompt for old postfix to remove if necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (if (and justify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (setq ada-fill-comment-old-postfix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (read-from-minibuffer "enter already existing postfix string: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ada-fill-comment-postfix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;; find limits of paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (message "filling comment paragraph ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (back-to-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ;; find end of paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (while (and (looking-at "--.*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (not (looking-at "--[ \t]*$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (back-to-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (setq end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (goto-char opos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; find begin of paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (back-to-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (while (and (looking-at "--.*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (not (looking-at "--[ \t]*$")))
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 (back-to-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; get indentation to calculate width for filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (ada-indent-current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (back-to-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (setq indent (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq begin (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;; delete old postfix if necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (if (and justify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (while (re-search-forward (concat ada-fill-comment-old-postfix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (replace-match "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; delete leading whitespace and uncomment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (while (re-search-forward "^[ \t]*--[ \t]*" end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (replace-match "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;; calculate fill width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (setq fill-column (- fill-column indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (length ada-fill-comment-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (if postfix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (length ada-fill-comment-postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; fill paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (fill-region begin (1- end) justify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (setq fill-column (+ fill-column indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (length ada-fill-comment-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (if postfix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (length ada-fill-comment-postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;; find end of second last line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (forward-line -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (setq end-2 (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; re-comment and re-indent region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (indent-to indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (insert ada-fill-comment-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (while (re-search-forward "\n" (1- end-2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (replace-match (concat "\n" ada-fill-comment-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (indent-to indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; append postfix if wanted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (if (and justify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 postfix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ada-fill-comment-postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; append postfix up to there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (while (re-search-forward "\n" (1- end-2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (replace-match (concat ada-fill-comment-postfix "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; fill last line and append postfix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (insert-char ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (- fill-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (length ada-fill-comment-postfix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (insert ada-fill-comment-postfix))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;; delete the extra line that gets inserted somehow(??)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (goto-char (1- end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (message "filling comment paragraph ... done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (goto-char opos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;;;--------------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;;; Call External Pretty Printer ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;;;--------------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (defun ada-call-pretty-printer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 "Calls the external Pretty Printer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 The name is specified in ada-external-pretty-print-program. Saves the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 current buffer in a directory specified by ada-tmp-directory,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 starts the Pretty Printer as external process on that file and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 reloads the beautyfied program in the buffer and cleans up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ada-tmp-directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (let ((filename-with-path buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (curbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (orgpos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (mesgbuf nil) ;; for byte-compiling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (file-path (file-name-directory buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (filename-without-path (file-name-nondirectory buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (tmp-file-with-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (concat ada-tmp-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (file-name-nondirectory buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ;; save buffer in temporary file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (message "saving current buffer to temporary file ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (write-file tmp-file-with-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (auto-save-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (message "saving current buffer to temporary file ... done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;; call external pretty printer program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (message "running external pretty printer ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ;; create a temporary buffer for messages of pretty printer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (setq mesgbuf (get-buffer-create "Pretty Printer Messages"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;; execute pretty printer on temporary file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (call-process ada-external-pretty-print-program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 nil mesgbuf t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 tmp-file-with-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 ;; display messages if there are some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (if (buffer-modified-p mesgbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;; show the message buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (display-buffer mesgbuf t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ;; kill the message buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (kill-buffer mesgbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (message "running external pretty printer ... done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 ;; kill current buffer and load pretty printer output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ;; or restore old buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (if (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 "Really replace current buffer with pretty printer output ? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (kill-buffer curbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (find-file tmp-file-with-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (message "old buffer contents restored"))
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 temporary file and restore information of current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (delete-file tmp-file-with-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (set-visited-file-name filename-with-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (auto-save-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (goto-char orgpos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ;;;---------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 ;;; auto-casing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ;;;---------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 ;; from Philippe Waroquiers <philippe@cfmu.eurocontrol.be>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ;; modifiedby RE and MH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (defun ada-after-keyword-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; returns t if cursor is after a keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (= (point) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (not (looking-at "_"))) ; (MH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (looking-at (concat ada-keywords "[^_]")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (defun ada-after-char-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;; returns t if after ada character "'". This is interpreted as being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; in a character constant.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (if (> (point) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (forward-char -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (looking-at "'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (defun ada-adjust-case (&optional force-identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 "Adjust the case of the word before the just-typed character,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 according to ada-case-keyword and ada-case-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 If FORCE-IDENTIFIER is non-nil then also adjust keyword as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 identifier." ; (MH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if (and (> (point) 1) (not (or (ada-in-string-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (ada-in-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (ada-after-char-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (if (eq (char-syntax (char-after (1- (point)))) ?w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (or (= (point) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (looking-at "'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (funcall ada-case-attribute -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (not force-identifier) ; (MH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (ada-after-keyword-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (funcall ada-case-keyword -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (funcall ada-case-identifier -1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (defun ada-adjust-case-interactive (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (let ((lastk last-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (cond ((or (eq lastk ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (eq lastk ?\r))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 ;; horrible kludge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (ada-adjust-case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;; horrible dekludge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (delete-backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;; some special keys and their bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ((eq lastk ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (funcall ada-lfd-binding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ((eq lastk ?\r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (funcall ada-ret-binding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ((eq lastk ?\C-i) (ada-tab))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 ((self-insert-command (prefix-numeric-value arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; if there is a keyword in front of the underscore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; then it should be part of an identifier (MH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (if (eq lastk ?_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (ada-adjust-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (ada-adjust-case))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (defun ada-activate-keys-for-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 ;; save original keybindings to allow swapping ret/lfd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;; when casing is activated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ;; the 'or ...' is there to be sure that the value will not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; be changed again when ada-mode is called more than once (MH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (or ada-ret-binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (setq ada-ret-binding (key-binding "\C-M")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (or ada-lfd-binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (setq ada-lfd-binding (key-binding "\C-j")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ;; call case modifying function after certain keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (mapcar (function (lambda(key) (define-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ada-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (char-to-string key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 'ada-adjust-case-interactive)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 '( ?` ?~ ?! ?@ ?# ?$ ?% ?^ ?& ?* ?( ?) ?- ?= ?+ ?[ ?{ ?] ?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ?_ ?\\ ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?? ?/ ?\n 32 ?\r )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ;; deleted ?\t from above list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;; added by MH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (defun ada-loose-case-word (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 "Capitalizes the first and the letters following _
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ARG is ignored, it's there to fit the standard casing functions' style."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (let ((pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (first t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (skip-chars-backward "a-zA-Z0-9_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (while (or first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (search-forward "_" pos t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (and first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (setq first nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (insert-char (upcase (following-char)) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (goto-char pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;; added by MH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (defun ada-adjust-case-region (from to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 "Adjusts the case of all identifiers and keywords in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ATTENTION: This function might take very long for big regions !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (let ((begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (keywordp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (reldiff nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (set-syntax-table ada-mode-symbol-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (goto-char to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ;; loop: look for all identifiers and keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (while (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 "[^a-zA-Z0-9_]\\([a-zA-Z0-9_]+\\)[^a-zA-Z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; print status message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (setq reldiff (- (point) from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (message (format "adjusting case ... %5d characters left"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (- (point) from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ;; do nothing if it is a string or comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (ada-in-string-or-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;; get the identifier or keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (setq keywordp (looking-at (concat ada-keywords "[^_]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (skip-chars-forward "a-zA-Z0-9_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; casing according to user-option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (if keywordp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (funcall ada-case-keyword -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (funcall ada-case-identifier -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (goto-char begin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (message "adjusting case ... done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (set-syntax-table ada-mode-syntax-table))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; added by MH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defun ada-adjust-case-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 "Adjusts the case of all identifiers and keywords in the whole buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ATTENTION: This function might take very long for big buffers !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (interactive "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (ada-adjust-case-region (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 ;;;------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 ;;; Format Parameter Lists ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 ;;;------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (defun ada-format-paramlist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 "Re-formats a parameter-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 ATTENTION: 1) Comments inside the list are killed !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 2) If the syntax is not correct (especially, if there are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 semicolons missing), it can get totally confused !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 In such a case, use 'undo', correct the syntax and try again."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (let ((begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (delend nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (paramlist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (set-syntax-table ada-mode-symbol-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ;; check if really inside parameter list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (or (ada-in-paramlist-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (error "not in 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 ;; find start of current parameter-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (concat "\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 "procedure\\|function\\|body\\|package\\|task\\|entry\\|accept"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 "\\)\\>") t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (ada-search-ignore-string-comment "(" nil nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; find end of parameter-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (setq delend (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 ;; find end of last parameter-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (ada-search-ignore-string-comment "[^ \t\n]" t nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ;; build a list of all elements of the parameter-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (setq paramlist (ada-scan-paramlist (1+ begin) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ;; delete the original parameter-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (delete-region begin (1- delend))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 ;; insert the new parameter-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (ada-insert-paramlist paramlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 ;; restore syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (set-syntax-table ada-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (defun ada-scan-paramlist (begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; Scans a parameter-list between BEGIN and END and returns a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ;; of its contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 ;; The list has the following format:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 ;; Name of Param in? out? accept? Name of Type Default-Exp or nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; ( ('Name_Param_1' t nil t Type_Param_1 ':= expression')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;; ('Name_Param_2' nil nil t Type_Param_2 nil) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (let ((paramlist (list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (param (list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (notend t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (apos nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (epos nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (semipos nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (match-cons nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;; loop until end of last parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (while notend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; find first character of parameter-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (ada-goto-next-non-ws)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (setq apos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ;; find last character of parameter-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (if (setq match-cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (ada-search-ignore-string-comment "[ \t\n]*;" nil end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (setq epos (car match-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (setq semipos (cdr match-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (setq epos end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 ;; read name(s) of parameter(s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (goto-char apos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (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
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (setq param (list (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (ada-search-ignore-string-comment ":" nil epos t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;; look for 'in'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (setq apos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (setq param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (append param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (consp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (ada-search-ignore-string-comment "\\<in\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 epos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ;; look for 'out'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (goto-char apos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (setq param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (append param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (consp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (ada-search-ignore-string-comment "\\<out\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 epos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 ;; look for 'accept'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (goto-char apos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (setq param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (append param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (consp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (ada-search-ignore-string-comment "\\<accept\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 epos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 ;; skip 'in'/'out'/'accept'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (goto-char apos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (ada-goto-next-non-ws)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (while (looking-at "\\<\\(in\\|out\\|accept\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (ada-goto-next-non-ws))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 ;; read type of parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (looking-at "\\<[a-zA-Z0-9_\\.]+\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (setq param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (append param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 ;; read default-expression, if there is one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (goto-char (setq apos (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (setq param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (append param
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (if (setq match-cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (ada-search-ignore-string-comment ":="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 epos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (buffer-substring (car match-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 epos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 ;; add this parameter-declaration to the list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (setq paramlist (append paramlist (list param)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; check if it was the last parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (if (eq epos end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (setq notend nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (goto-char semipos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 ) ; end of loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (reverse paramlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (defun ada-insert-paramlist (paramlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 ;; Inserts a formatted PARAMLIST in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;; See doc of ada-scan-paramlist for the format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (let ((i (length paramlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (parlen 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (typlen 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (temp 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (inp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (outp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (acceptp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (column nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (orgpoint 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (firstcol nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 ;; loop until last parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (while (not (zerop i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (setq i (1- i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 ;; get max length of parameter-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (setq parlen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (if (<= parlen (setq temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (length (nth 0 (nth i paramlist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 parlen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 ;; get max length of type-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (setq typlen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (if (<= typlen (setq temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (length (nth 4 (nth i paramlist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 typlen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 ;; is there any 'in' ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (setq inp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (or inp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (nth 1 (nth i paramlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 ;; is there any 'out' ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (setq outp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (or outp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (nth 2 (nth i paramlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 ;; is there any 'accept' ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (setq acceptp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (or acceptp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (nth 3 (nth i paramlist))))) ; end of loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;; does paramlist already start on a separate line ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (re-search-backward "^.\\|[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (looking-at "^."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; yes => re-indent it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (ada-indent-current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; no => insert newline and indent it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (ada-indent-current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (setq orgpoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (setq column (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (funcall (ada-indent-function) orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (indent-to column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (insert "(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (setq firstcol (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (setq i (length paramlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; loop until last parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (while (not (zerop i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (setq i (1- i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (setq column firstcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 ;; insert parameter-name, space and colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (insert (nth 0 (nth i paramlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (indent-to (+ column parlen 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (insert ": ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (setq column (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ;; insert 'in' or space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (if (nth 1 (nth i paramlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (insert "in ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (or inp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 acceptp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (not (nth 3 (nth i paramlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; insert 'out' or space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (if (nth 2 (nth i paramlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (insert "out ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (or outp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 acceptp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (not (nth 3 (nth i paramlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ;; insert 'accept'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (if (nth 3 (nth i paramlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (insert "accept "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (setq column (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 ;; insert type-name and, if necessary, space and default-expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (insert (nth 4 (nth i paramlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (if (nth 5 (nth i paramlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (indent-to (+ column typlen 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (insert (nth 5 (nth i paramlist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ;; check if it was the last parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (if (not (zerop i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ;; no => insert ';' and newline and indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (progn
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 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (indent-to firstcol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; yes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (insert ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ) ; end of loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ;; if anything follows, except semicolon:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; put it in a new line and indent it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (if (not (looking-at "[ \t]*[;\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (ada-indent-newline-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ))
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 ;;;----------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 ;;; Move To Matching Start/End ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;;;----------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (defun ada-move-to-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 "Moves point to the matching start of the current end ... around point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (let ((pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (set-syntax-table ada-mode-symbol-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (message "searching for block start ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ;; do nothing if in string or comment or not on 'end ...;'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 ;; or if an error occurs during processing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (ada-in-string-or-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (and (progn
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 (backward-word 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (or (looking-at "[ \t]*\\<end\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (backward-word 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (or (looking-at "[ \t]*\\<end\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (error "not on end ...;")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (ada-goto-matching-start 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (setq pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ;; on 'begin' => go on, according to user option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 ada-move-to-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (looking-at "\\<begin\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (ada-goto-matching-decl-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (setq pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ) ; end of save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ;; now really move to the found position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (goto-char pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (message "searching for block start ... done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ;; restore syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (set-syntax-table ada-mode-syntax-table))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (defun ada-move-to-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 "Moves point to the matching end of the current block around point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 Moves to 'begin' if in a declarative part."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (let ((pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (decstart nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (packdecl nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (set-syntax-table ada-mode-symbol-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (message "searching for block end ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 ;; directly on 'begin'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (ada-goto-previous-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (looking-at "\\<begin\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (ada-goto-matching-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 ;; on first line of defun declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (and (ada-goto-stmt-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (looking-at "\\<function\\>\\|\\<procedure\\>" )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (ada-search-ignore-string-comment "\\<begin\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 ;; on first line of task declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (and (ada-goto-stmt-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (looking-at "\\<task\\>" )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (ada-search-ignore-string-comment "[^ \n\t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (not (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (looking-at "\\<body\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (ada-search-ignore-string-comment "\\<begin\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 ;; accept block start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (and (ada-goto-stmt-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (looking-at "\\<accept\\>" )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (ada-goto-matching-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 ;; package start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (and (ada-goto-matching-decl-start t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (looking-at "\\<package\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (ada-goto-matching-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 ;; inside a 'begin' ... 'end' block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (ada-goto-matching-decl-start t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (ada-search-ignore-string-comment "\\<begin\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;; (hopefully ;-) everything else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (ada-goto-matching-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (setq pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 ) ; end of save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ;; now really move to the found position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (goto-char pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (message "searching for block end ... done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;; restore syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (set-syntax-table ada-mode-syntax-table))))
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 ;;;-----------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 ;;; Functions For Indentation ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 ;;;-----------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 ;; ---- main functions for indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (defun ada-indent-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 "Indents the region using ada-indent-current on each line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (let ((block-done 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (lines-remaining (count-lines beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (msg (format "indenting %4d lines %%4d lines remaining ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (count-lines beg end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (endmark (copy-marker end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 ;; catch errors while indenting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (while (< (point) endmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (if (> block-done 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (progn (message (format msg lines-remaining))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (setq block-done 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (if (looking-at "^$") nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (ada-indent-current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (setq block-done (1+ block-done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (setq lines-remaining (1- lines-remaining)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 ;; show line number where the error occured
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (error (format "line %d: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (1+ (count-lines (point-min) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 err) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (message "indenting ... done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (defun ada-indent-newline-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 "Indents the current line, inserts a newline and then indents the new line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (interactive "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (let ((column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (ada-indent-current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (setq orgpoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (set-syntax-table ada-mode-symbol-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 (setq column (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (funcall (ada-indent-function) orgpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ;; restore syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (set-syntax-table ada-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (indent-to column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 ;; The following is needed to ensure that indentation will still be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 ;; correct if something follows behind point when typing LFD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 ;; For example: Imagine point to be there (*) when LFD is typed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ;; while cond loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 ;; null; *end loop;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 ;; Result without the following statement would be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 ;; while cond loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;; null;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 ;; *end loop;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 ;; You would then have to type TAB to correct it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 ;; If that doesn't bother you, you can comment out the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 ;; statement to speed up indentation a LITTLE bit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (if (not (looking-at "[ \t]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (ada-indent-current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (defun ada-indent-current ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 "Indents current line as Ada code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 This works by two steps:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 1) It moves point to the end of the previous code-line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 Then it calls the function to calculate the indentation for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 following line as if a newline would be inserted there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 The calculated column # is saved and the old position of point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 is restored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 2) Then another function is called to calculate the indentation for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 the current line, based on the previously calculated column #."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (set-syntax-table ada-mode-symbol-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (let ((line-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (orgpoint (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (cur-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (prev-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (prevline 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 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;; first step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (if (ada-goto-prev-nonblank-line t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;; we are not in the first accessible line in the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;;(end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;;(forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ;; we are already at the BOL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (setq line-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (setq prev-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (funcall (ada-indent-function) line-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (setq prevline nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (if prevline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; we are not in the first accessible line in the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;; second step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (back-to-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (setq cur-indent (ada-get-current-indent prev-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (indent-to cur-indent)
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))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (ada-search-ignore-string-comment (concat ada-subprog-start-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 "\\|\\<package\\>") t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (ada-get-indent-noindent orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 ;; something follows 'is'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 ((and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 foundis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (ada-goto-next-non-ws)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 (funcall (ada-indent-function t) orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 ;; no 'is' but ';'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (ada-search-ignore-string-comment ";" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 cur-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 ;; no 'is' or ';'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (+ cur-indent ada-broken-indent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (defun ada-get-indent-noindent (orgpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 ;; Returns the indentation (column #) for the new line after ORGPOINT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 ;; Assumes point to be at the beginning of a 'noindent statement'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (ada-search-ignore-string-comment ";" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (+ (current-indentation) ada-broken-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (defun ada-get-indent-label (orgpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 ;; Returns the indentation (column #) for the new line after ORGPOINT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 ;; Assumes point to be at the beginning of a label or variable declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 ;; 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
2169 ;; This check might be a bit slow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (let ((match-cons nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (cur-indent (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (goto-char (cdr (ada-search-ignore-string-comment ":")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 ;; loop label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 (setq match-cons (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ada-loop-start-re nil orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (goto-char (car match-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (ada-get-indent-loop orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 ;; declare label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (setq match-cons (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 "\\<declare\\>" nil orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (goto-char (car match-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (+ (current-indentation) ada-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 ;; complete statement following colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (ada-search-ignore-string-comment ";" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (if (ada-in-decl-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 cur-indent ; variable-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (- cur-indent ada-label-indent))) ; label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 ;; broken statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (if (ada-in-decl-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (+ cur-indent ada-broken-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (+ cur-indent ada-broken-indent (- ada-label-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 ;; nothing follows colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (if (ada-in-decl-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 (+ cur-indent ada-broken-indent) ; variable-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (- cur-indent ada-label-indent)))))) ; label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (defun ada-get-indent-loop (orgpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 ;; Returns the indentation (column #) for the new line after ORGPOINT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 ;; Assumes point to be at the beginning of a loop statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 ;; or (unfortunately) also a for ... use statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (let ((match-cons nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 ;; statement complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (ada-search-ignore-string-comment ";" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ;; simple loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 ((looking-at "loop\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (ada-get-indent-block-start orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 ;; 'for'- loop (or also a for ... use statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 ((looking-at "for\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 ;; for ... use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (not (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (not (zerop (skip-chars-forward "_a-zA-Z0-9'")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (not (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (looking-at "\\<use\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 ;; check if there is a 'record' before point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (setq match-cons (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 "\\<record\\>" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 (if match-cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 (goto-char (car match-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (+ (current-indentation) ada-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 ;; for..loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (setq match-cons (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 "\\<loop\\>" nil orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 (goto-char (car match-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ;; indent according to 'loop', if it's first in the line;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 ;; otherwise to 'for'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (if (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 (back-to-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 (looking-at "\\<loop\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 (goto-char pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (+ (current-indentation) ada-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ;; for-statement is broken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (+ (current-indentation) ada-broken-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 ;; 'while'-loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 ((looking-at "while\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 ;; while..loop ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 (setq match-cons (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 "\\<loop\\>" nil orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 (goto-char (car match-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 ;; indent according to 'loop', if it's first in the line;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 ;; otherwise to 'while'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (if (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 (back-to-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (looking-at "\\<loop\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 (goto-char pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (+ (current-indentation) ada-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (+ (current-indentation) ada-broken-indent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (defun ada-get-indent-type (orgpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 ;; Returns the indentation (column #) for the new line after ORGPOINT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 ;; Assumes point to be at the beginning of a type statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (let ((match-dat nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 ;; complete record declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (setq match-dat (ada-search-ignore-string-comment "\\<end\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (ada-goto-next-non-ws)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (looking-at "\\<record\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (ada-goto-next-non-ws)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (looking-at ";")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (goto-char (car match-dat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 ;; record type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 (setq match-dat (ada-search-ignore-string-comment "\\<record\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (goto-char (car match-dat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (+ (current-indentation) ada-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 ;; complete type declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (ada-search-ignore-string-comment ";" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 ;; "type ... is", but not "type ... is ...", which is broken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 (ada-search-ignore-string-comment "\\<is\\>" nil orgpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (not (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (+ (current-indentation) ada-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 ;; broken statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (+ (current-indentation) ada-broken-indent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 ;;; ---- support-functions for indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 ;;; ---- searching and matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (defun ada-goto-stmt-start (&optional limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 ;; Moves point to the beginning of the statement that point is in or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 ;; after. Returns the new position of point. Beginnings are found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 ;; by searching for 'ada-end-stmt-re' and then moving to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 ;; following non-ws that is not a comment. LIMIT is actually not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 ;; used by the indentation functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 (let ((match-dat nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (orgpoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 (setq match-dat (ada-search-prev-end-stmt limit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (if match-dat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 ;; found a previous end-statement => check if anything follows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (if (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (goto-char (cdr match-dat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 "[^ \t\n]" nil orgpoint)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 ;; nothing follows => it's the end-statement directly in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 ;; front of point => search again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 (setq match-dat (ada-search-prev-end-stmt limit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 ;; if found the correct end-stetement => goto next non-ws
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (if match-dat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (goto-char (cdr match-dat)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (ada-goto-next-non-ws))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 ;; no previous end-statement => we are at the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 ;; accessible part of the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 ;; skip to the very first statement, if there is one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 (if (setq match-dat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 "[^ \t\n]" nil orgpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 (goto-char (car match-dat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 (goto-char orgpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (defun ada-search-prev-end-stmt (&optional limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 ;; Moves point to previous end-statement. Returns a cons cell whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 ;; car is the beginning and whose cdr the end of the match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;; End-statements are defined by 'ada-end-stmt-re'. Checks for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 ;; certain keywords if they follow 'end', which means they are no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 ;; end-statement there.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (backward-word 1)))) ; end of loop
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 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 ;; Moves point to the beginning of the previous word of ada-code.
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 "\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (error (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 "matching start is not '"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 keyword "'"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (defun ada-check-defun-name (defun-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 ;; Checks if the name of the matching defun really is DEFUN-NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 ;; Assumes point to be already positioned by 'ada-goto-matching-start'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 ;; Moves point to the beginning of the declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 ;; 'accept' or 'package' ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (if (not (looking-at "\\<\\(accept\\|package\\|task\\|protected\\)\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (ada-goto-matching-decl-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 ;; 'begin' of 'procedure'/'function'/'task' or 'declare'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 ;; a named 'declare'-block ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 (if (looking-at "\\<declare\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 (ada-goto-stmt-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 ;; no, => 'procedure'/'function'/'task'/'protected'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (forward-word 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (backward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;; skip 'body' 'protected' 'type'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 (if (looking-at "\\<\\(body\\|type\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (forward-word 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (backward-sexp 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 ;; should be looking-at the correct name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (if (not (looking-at (concat "\\<" defun-name "\\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 "matching defun has different name: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (point))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (defun ada-goto-matching-decl-start (&optional noerror nogeneric)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 ;; Moves point to the matching declaration start of the current 'begin'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 ;; If NOERROR is non-nil, it only returns nil if no match was found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 (let ((nest-count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (pos nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 (first t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 (flag nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 ;; search backward for interesting keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (while (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 (not (zerop nest-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (ada-search-ignore-string-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (concat "\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 "is\\|separate\\|end\\|declare\\|new\\|begin\\|generic"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 "\\)\\>") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 ;; calculate nest-depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 ((looking-at "end")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 (ada-goto-matching-start 1 noerror)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 (if (looking-at "begin")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (setq nest-count (1+ nest-count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 ((looking-at "declare\\|generic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 (setq nest-count (1- nest-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (setq first nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 ((looking-at "is")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 ;; check if it is only a type definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (ada-goto-previous-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (skip-chars-backward "a-zA-Z0-9_.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (looking-at ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (skip-chars-backward "a-zA-Z0-9_.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (ada-goto-previous-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (looking-at "\\<type\\>")) ; end of save-excursion
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (error "no matching procedure/function/task/declare/package"))
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.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (save-excursion (and (re-search-backward "\\(--\\|\n\\)" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 (looking-at "-"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (defun ada-in-string-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 ;; Returns t if point is inside a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 ;; (Taken from pascal-mode.el, modified by MH).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 (nth 3 (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 (point)) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 ;; check if 'string quote' is only a character constant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 (re-search-backward "\"" nil t) ; # not a string delimiter anymore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 (not (= (char-after (1- (point))) ?'))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 (defun ada-in-string-or-comment-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 ;; Returns t if point is inside a string or a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 (or (ada-in-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 (ada-in-string-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 (defun ada-in-paramlist-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 ;; Returns t if point is inside a parameter-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 ;; following 'function'/'procedure'/'package'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 (re-search-backward "(\\|)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 ;; inside parentheses ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 (looking-at "(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 (backward-word 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 ;; right keyword before paranthesis ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 (looking-at (concat "\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 "procedure\\|function\\|body\\|package\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 "task\\|entry\\|accept\\)\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (re-search-forward ")\\|:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 ;; at least one ':' inside the parentheses ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 (not (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 (looking-at ":"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 ;; not really a boolean function ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 (defun ada-in-open-paren-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 ;; If point is somewhere behind an open parenthesis not yet closed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 ;; it returns the column # of the first non-ws behind this open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 ;; parenthesis, otherwise nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 (let ((start (if (< (point) ada-search-paren-char-count-limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 (- (point) ada-search-paren-char-count-limit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 parse-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 (col nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 (setq parse-result (parse-partial-sexp start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 (if (nth 1 parse-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 (goto-char (1+ (nth 1 parse-result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 (re-search-forward "[^ \t]" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 (not (looking-at "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 (setq col (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 col
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 ;;;----------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 ;;; Behaviour Of TAB Key ;;;
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 (defun ada-tab ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 "Do indenting or tabbing according to `ada-tab-policy'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 (cond ((eq ada-tab-policy 'indent-and-tab) (error "not implemented"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 ;; ada-indent-and-tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 ((eq ada-tab-policy 'indent-auto) (ada-indent-current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 ((eq ada-tab-policy 'gei) (ada-tab-gei))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 ((eq ada-tab-policy 'indent-af) (af-indent-line)) ; GEB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 (defun ada-untab (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 "Delete leading indenting according to `ada-tab-policy'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 ((eq ada-tab-policy 'indent-af) (backward-delete-char-untabify ; GEB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 (prefix-numeric-value arg) ; GEB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 arg)) ; GEB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 ((eq ada-tab-policy 'indent-auto) (error "not implemented"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 (defun ada-indent-current-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 "Ada Mode version of the indent-line-function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 (interactive "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 (let ((starting-point (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 (ada-beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 (ada-tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 (if (< (point) starting-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 (goto-char starting-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 (set-marker starting-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 (defun ada-tab-hard ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 "Indent current line to next tab stop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 (insert-char ? ada-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 (if (save-excursion (= (point) (progn (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 (forward-char ada-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 (defun ada-untab-hard ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 "indent current line to previous tab stop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 (let ((bol (save-excursion (progn (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 (eol (save-excursion (progn (end-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 (indent-rigidly bol eol (- 0 ada-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 ;;;---------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 ;;; Miscellaneous ;;;
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 (defun ada-remove-trailing-spaces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 ;; remove all trailing spaces at the end of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 "remove trailing spaces in the whole buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 (while (re-search-forward "[ \t]+$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 (replace-match "" nil nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 (defun ada-untabify-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 ;; change all tabs to spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (untabify (point-min) (point-max))))
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-uncomment-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 "delete comment-start at the beginning of a line in the region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (comment-region beg end -1))
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 ;; define a function to support find-file.el if loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (defun ada-ff-other-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 "Find other file in other window using ff-find-other-file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 (and (fboundp 'ff-find-other-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 (ff-find-other-file t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 ;;;-------------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 ;;; Moving To Procedures/Packages ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 ;;;-------------------------------;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 (defun ada-next-procedure ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 "Moves point to next procedure."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 (if (re-search-forward ada-procedure-start-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 (error "No more functions/procedures/tasks")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 (defun ada-previous-procedure ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 "Moves point to previous procedure."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 (if (re-search-backward ada-procedure-start-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 (error "No more functions/procedures/tasks")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 (defun ada-next-package ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 "Moves point to next package."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 (if (re-search-forward ada-package-start-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 (error "No more packages")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (defun ada-previous-package ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 "Moves point to previous package."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 (if (re-search-backward ada-package-start-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 (error "No more packages")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 ;;;-----------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 ;;; define keymap for Ada
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 ;;;-----------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 (if (not ada-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 (setq ada-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 ;; Indentation and Formatting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 (define-key ada-mode-map "\t" 'ada-tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 (define-key ada-mode-map "\C-c\C-l" 'ada-indent-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 (if (ada-xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 (define-key ada-mode-map '(shift tab) 'ada-untab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (define-key ada-mode-map [S-tab] 'ada-untab))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 (define-key ada-mode-map "\C-c\C-p" 'ada-call-pretty-printer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 ;;; We don't want to make meta-characters case-specific.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 ;;; (define-key ada-mode-map "\M-Q" 'ada-fill-comment-paragraph-justify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 (define-key ada-mode-map "\M-\C-q" 'ada-fill-comment-paragraph-postfix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 ;; Movement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 ;;; It isn't good to redefine these. What should be done instead? -- rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 ;;; (define-key ada-mode-map "\M-e" 'ada-next-package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 ;;; (define-key ada-mode-map "\M-a" 'ada-previous-package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 (define-key ada-mode-map "\M-\C-e" 'ada-next-procedure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 (define-key ada-mode-map "\M-\C-a" 'ada-previous-procedure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 (define-key ada-mode-map "\C-c\C-a" 'ada-move-to-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 (define-key ada-mode-map "\C-c\C-e" 'ada-move-to-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 ;; Compilation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 (define-key ada-mode-map "\C-c\C-c" 'compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 ;; Casing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 (define-key ada-mode-map "\C-c\C-r" 'ada-adjust-case-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 (define-key ada-mode-map "\C-c\C-b" 'ada-adjust-case-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 (define-key ada-mode-map "\177" 'backward-delete-char-untabify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 ;; Use predefined function of emacs19 for comments (RE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 (define-key ada-mode-map "\C-c;" 'comment-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 (define-key ada-mode-map "\C-c:" 'ada-uncomment-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 ;; Change basic functionality
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 ;; substitute-key-definition is not defined equally in GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 ;; and XEmacs, you cannot put in an optional 4th parameter in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 ;; 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
3317 ;; GNU Emacs as well. If you encounter any problems with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 ;; following three functions, please tell me. RE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 (mapcar (function (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 (substitute-key-definition (car pair) (cdr pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 ada-mode-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 '((beginning-of-line . ada-beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323 (end-of-line . ada-end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 (forward-to-indentation . ada-forward-to-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 ;; else GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 ;;(mapcar (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 ;; (substitute-key-definition (car pair) (cdr pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 ;; ada-mode-map global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 ;;;-------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 ;;; define menu 'Ada'
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 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 (defun ada-add-ada-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341 "Adds the menu 'Ada' to the menu-bar in Ada Mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 (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
3343 '("Ada"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 ["Next Package" ada-next-package t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 ["Previous Package" ada-previous-package t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 ["Next Procedure" ada-next-procedure t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 ["Previous Procedure" ada-previous-procedure t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 ["Goto Start" ada-move-to-start t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 ["Goto End" ada-move-to-end t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 ["------------------" nil nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 ["Indent Current Line (TAB)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 ada-indent-current-function t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 ["Indent Lines in Region" ada-indent-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 ["Format Parameter List" ada-format-paramlist t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 ["Pretty Print Buffer" ada-call-pretty-printer 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 ["Fill Comment Paragraph"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 ada-fill-comment-paragraph t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 ["Justify Comment Paragraph"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 ada-fill-comment-paragraph-justify t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 ["Postfix Comment Paragraph"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362 ada-fill-comment-paragraph-postfix t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 ["------------" nil nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 ["Adjust Case Region" ada-adjust-case-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 ["Adjust Case Buffer" ada-adjust-case-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 ["----------" nil nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 ["Comment Region" comment-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 ["Uncomment Region" ada-uncomment-region 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 ["Compile" compile (fboundp 'compile)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 ["Next Error" next-error (fboundp 'next-error)]
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 ["Index" imenu (fboundp 'imenu)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 ["--------------" nil nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 ["Other File Other Window" ada-ff-other-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 (fboundp 'ff-find-other-file)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 ["Other File" ff-find-other-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 (fboundp 'ff-find-other-file)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 (if (ada-xemacs) (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 (easy-menu-add ada-mode-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 (setq mode-popup-menu (cons "Ada Mode" ada-mode-menu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 ;;;-------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 ;;; Define Some Support Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 ;;;-------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 (defun ada-beginning-of-line (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 ((eq ada-tab-policy 'indent-af) (af-beginning-of-line arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 (t (beginning-of-line arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 (defun ada-end-of-line (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 ((eq ada-tab-policy 'indent-af) (af-end-of-line arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 (t (end-of-line arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 (defun ada-current-column ()
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-current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 (t (current-column))
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-forward-to-indentation (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 ((eq ada-tab-policy 'indent-af) (af-forward-to-indentation arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413 (t (forward-to-indentation arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416 ;;;---------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 ;;; support for find-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 ;;;---------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 (defun ada-make-filename-from-adaname (adaname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423 "determine the filename of a package/procedure from its own Ada name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424 ;; this is done simply by calling gkrunch, when we work with GNAT. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425 ;; must be a more complex function in other compiler environments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 (interactive "s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 ;; things that should really be done by the external process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429 ;; 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
3430 ;; previous version, just uncomment the following lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 (let (krunch-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 (setq krunch-buf (generate-new-buffer "*gkrunch*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434 (set-buffer krunch-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 ; (insert (downcase adaname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437 ; (while (search-forward "." nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438 ; (replace-match "-" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 ; (setq adaname (buffer-substring (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3440 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 ; (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 ; (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 ; ;; clean the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445 ; (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3446 ;; send adaname to external process "gnatk8"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447 (call-process "gnatk8" nil krunch-buf nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 adaname ada-krunch-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 ;; fetch output of that process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 (setq adaname (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 (kill-buffer krunch-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 (setq adaname adaname) ;; can I avoid this statement?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461 ;;; functions for placing the cursor on the corresponding subprogram
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 (defun ada-which-function-are-we-in ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 "Determine whether we are on a function definition/declaration and remember
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 the name of that function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 (setq ff-function-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 (if (re-search-backward ada-procedure-start-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 (setq ff-function-name (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 ; we didn't find a procedure start, perhaps there is a package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 (if (re-search-backward ada-package-start-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 (setq ff-function-name (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 ;;;---------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 ;;; support for imenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 ;;;---------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 (defun imenu-create-ada-index (&optional regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 "create index alist for Ada files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 (let ((index-alist '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 prev-pos char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 ;(imenu-progress-message prev-pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 ;; Search for functions/procedures
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 (or regexp ada-procedure-start-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 ;(imenu-progress-message prev-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 ;; do not store forward definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 ;; right now we store them. We want to avoid them only in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 ;; package bodies, not in the specs!! ???RE???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499 ; (if (not (looking-at (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 ; "[ \t\n]*" ; WS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501 ; "\([^)]+\)" ; parameterlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 ; "\\([ \n\t]+return[ \n\t]+"; potential return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 ; "[a-zA-Z0-9_\\.]+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 ; "[ \t]*" ; WS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 ; ";" ;; THIS is what we really look for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 ; )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507 ; ; (push (imenu-example--name-and-position) index-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 (setq index-alist (cons (imenu-example--name-and-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 index-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510 ; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512 ;(imenu-progress-message 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3513 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514 (nreverse index-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3516 ;;;---------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517 ;;; support for font-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3518 ;;;---------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520 ;; 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
3521 ;; non-string quote context (the former as an operator, the latter as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 ;; a character string). We follow the least losing solution, in which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 ;; only " is a string quote. Therefore a character string of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524 ;; '"' will throw fontification off on the wrong track.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3526 (defconst ada-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 ;; accept, entry, function, package (body), protected (body|type),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 ;; pragma, procedure, task (body) plus name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 (list (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 "\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 "accept\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 "entry\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 "function\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 "package\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537 "package[ \t]+body\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 "procedure\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539 "protected\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 "protected[ \t]+body\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541 "protected[ \t]+type\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542 ;; "p\\(\\(ackage\\|rotected\\)\\(\\|[ \t]+\\(body\\|type\\)\\)\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3543 ;;\\|r\\(agma\\|ocedure\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3544 "task\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 "task[ \t]+body\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3546 "task[ \t]+type"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547 ;; "task\\(\\|[ \t]+body\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548 "\\)\\>[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3549 "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550 '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 "For consideration as a value of `ada-font-lock-keywords'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 This does fairly subdued highlighting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 (defconst ada-font-lock-keywords-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555 (append ada-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 ;; Main keywords, except those treated specially below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559 (concat "\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 ; ("abort" "abs" "abstract" "accept" "access" "aliased" "all"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 ; "and" "array" "at" "begin" "case" "declare" "delay" "delta"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 ; "digits" "do" "else" "elsif" "entry" "exception" "exit" "for"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 ; "generic" "if" "in" "is" "limited" "loop" "mod" "not"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 ; "null" "or" "others" "private" "protected"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 ; "range" "record" "rem" "renames" "requeue" "return" "reverse"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566 ; "select" "separate" "tagged" "task" "terminate" "then" "until"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 ; "while" "xor")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 "a\\(b\\(ort\\|s\\(\\|tract\\)\\)\\|cce\\(pt\\|ss\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 "l\\(iased\\|l\\)\\|nd\\|rray\\|t\\)\\|begin\\|case\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 "d\\(e\\(clare\\|l\\(ay\\|ta\\)\\)\\|igits\\|o\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571 "e\\(ls\\(e\\|if\\)\\|ntry\\|x\\(ception\\|it\\)\\)\\|for\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 "generic\\|i[fns]\\|l\\(imited\\|oop\\)\\|mod\\|n\\(ot\\|ull\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573 "o\\(r\\|thers\\|ut\\)\\|pr\\(ivate\\|otected\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 "r\\(ange\\|e\\(cord\\|m\\|names\\|queue\\|turn\\|verse\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 "se\\(lect\\|parate\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 "t\\(agged\\|erminate\\|hen\\)\\|until\\|" ; task removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 "wh\\(ile\\|en\\)\\|xor" ; "when" added
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 "\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 ;; Anything following end and not already fontified is a body name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 '("\\<\\(end\\)\\>[ \t]+\\(\\sw+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584 ;; Variable name plus optional keywords followed by a type name. Slow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585 ; (list (concat "\\<\\(\\sw+\\)\\>[ \t]*:?[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 ; "\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)?[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 ; "\\(\\sw+\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 ; '(1 font-lock-variable-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 ; '(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
3590 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3591 ;; Optional keywords followed by a type name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3592 (list (concat ; ":[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593 "\\<\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594 "[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595 "\\(\\sw+\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596 '(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
3597 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 ;; Keywords followed by a type or function name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 (list (concat "\\<\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 "new\\|of\\|subtype\\|type"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 "\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*\\((\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 '(1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 '(2 (if (match-beginning 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 'font-lock-function-name-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 'font-lock-type-face) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 ;; Keywords followed by a (comma separated list of) reference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)\\>" ; "when" removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 ; "[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?") ; RE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610 "[ \t]*\\([a-zA-Z0-9_\\.\\|, ]+\\)\\W")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 ;; Goto tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 "For consideration as a value of `ada-font-lock-keywords'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 This does a lot more highlighting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 ;(defconst ada-font-lock-keywords (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620 ; (let ((ident "\\(\\(\\sw\\|\\s_\\)+\\)") ; indent is 2nd capture
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621 ; (decl-1 "\\(procedure\\|function\\|package\\)[ \t]+") ; 1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 ; (decl-2 "\\(task\\|package\\)[ \t]+body[ \t]+") ; 1()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 ; (kwords-1 ; "normal" keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 ; '("abort" "abs" "accept" "access" "array" "begin" "body" "case"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 ; "constant" "declare" "delay" "delta" "digits" "else" "elsif"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 ; "entry" "exception" "exit" "function" "generic" "goto" "if"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627 ; "others" "limited" "loop" "mod" "new" "null" "out" "subtype"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 ; "package" "pragma" "private" "procedure" "raise" "range" "record"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 ; "rem" "renames" "return" "reverse" "select" "separate" "task"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3630 ; "terminate" "then" "type" "when" "while" "with" "xor"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3631 ; (kwords-2 ; keywords that may appear at the end of a word AND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3632 ; ; may also be preceeded by a non-space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3633 ; '("and" "at" "do" "end" "for" "in" "is" "not" "of" "or" "use"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3634 ; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3635 ; (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3636 ; ;;'("\\(--.*\\)" 1 font-lock-comment-face t) ; syntax table should do this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3637 ; (list (concat "^[ \t]*" decl-2 ident) 3 'font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3638 ; (list (concat "^[ \t]*" decl-1 ident) 3 'font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3639 ; (cons (concat "\\(" (mapconcat 'identity kwords-1 "\\|") "\\)[ \n\t;(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3640 ; 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3641 ; (cons (concat "[ \t+=*/---]\\(" (mapconcat 'identity kwords-2 "\\|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3642 ; "\\)[ \n\t;(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3643 ; 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3644 ; (cons "^\\(end\\)[ \n\t;(]" 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3645 ; (cons "\\.\\(all\\)" 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3646 ; )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3647 ; "Expressions to highlight in Ada buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3649 (defvar ada-font-lock-keywords (if font-lock-maximum-decoration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3650 ada-font-lock-keywords-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3651 ada-font-lock-keywords-1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3652 "*Expressions to highlight in Ada mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3654 (put 'ada-mode 'font-lock-defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3655 '(ada-font-lock-keywords nil t ((?\_ . "w"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3657 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3658 ;;; ????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3659 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3660 (defun ada-gen-comment-until-proc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3661 ;; comment until spec of a procedure or a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3662 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3663 (set-mark-command (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3664 (if (re-search-forward ada-procedure-start-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3665 (progn (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3666 (comment-region (mark) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3667 (error "No more functions/procedures")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3670 (defun ada-gen-treat-proc (match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3671 ;; make dummy body of a procedure/function specification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3672 ;; MATCH is a cons cell containing the start and end location of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3673 ;; last search for ada-procedure-start-regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3674 (goto-char (car match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3675 (let (proc-found func-found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3676 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3677 ((or (setq proc-found (looking-at "^[ \t]*procedure"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3678 (setq func-found (looking-at "^[ \t]*function")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3679 ;; treat it as a proc/func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 (forward-word 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682 (setq procname (buffer-substring (point) (cdr match))) ; store proc name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3684 ;; goto end of procname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3685 (goto-char (cdr match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3687 ;; skip over parameterlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3688 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689 ;; if function, skip over 'return' and result type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3690 (if func-found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3694 (setq functype (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 (skip-chars-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697 "a-zA-Z0-9_\.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3698 (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699 ;; look for next non WS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3700 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701 ((looking-at "[ \t]*;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3702 (delete-region (match-beginning 0) (match-end 0)) ;; delete the ';'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3703 (ada-indent-newline-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 (insert " is")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705 (ada-indent-newline-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 (if func-found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708 (insert "Result : ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709 (insert functype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710 (insert ";")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711 (ada-indent-newline-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 (insert "begin -- ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713 (insert procname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3714 (ada-indent-newline-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715 (insert "null;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3716 (ada-indent-newline-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 (if func-found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3718 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3719 (insert "return Result;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720 (ada-indent-newline-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721 (insert "end ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3722 (insert procname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723 (insert ";")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3724 (ada-indent-newline-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3725 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3726 ;; else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3727 ((looking-at "[ \t\n]*is")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3728 ;; do nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3729 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3730 ((looking-at "[ \t\n]*rename")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3731 ;; do nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3732 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3733 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3734 (message "unknown syntax")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3735 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3738 (defun ada-make-body ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3739 "Create an Ada package body in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3740 The potential old buffer contents is deleted first, then we copy the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3741 spec buffer in here and modify it to make it a body.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3743 This function typically is to be hooked into `ff-file-created-hooks'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3744 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3745 (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3746 (insert-buffer (car (cdr (buffer-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3747 (ada-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3749 (let (found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3750 (if (setq found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751 (ada-search-ignore-string-comment ada-package-start-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 (progn (goto-char (cdr found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753 (insert " body")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 ;; (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755 ;;(comment-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 (error "No package"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 ;; (comment-until-proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760 ;; does not work correctly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3761 ;; must be done by hand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763 (while (setq found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3764 (ada-search-ignore-string-comment ada-procedure-start-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3765 (ada-gen-treat-proc found))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768 ;;; provide ourself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3770 (provide 'ada-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772 ;;; ada-mode.el ends here