annotate lisp/progmodes/ada-mode.el @ 11002:ff115809a39e

(Fash): Fix previous change.
author Richard M. Stallman <rms@gnu.org>
date Tue, 14 Mar 1995 18:38:28 +0000
parents 7c5fe757600b
children 394f205af26d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; ada-mode.el - An Emacs major-mode for editing Ada source.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;;; Copyright (C) 1994 Free Software Foundation, Inc.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;;; Authors: Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;;; Rolf Ebert <ebert@inf.enst.fr>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;;; This file is part of GNU Emacs.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; any later version.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;;; This mode is a complete rewrite of a major mode for editing Ada 83
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; and Ada 94 source code under Emacs-19. It contains completely new
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; indenting code and support for code browsing (see ada-xref).
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; USAGE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;; =====
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;; If you have modified your startup file as described above, emacs
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;; should enter ada-mode when you load an ada source into emacs.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;; When you have entered ada-mode, you may get more info by pressing
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;; C-h m. You may also get online help describing various functions by:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;; C-h d <Name of function you want described>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;; HISTORY
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;; =======
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;;; The first Ada mode for GNU Emacs was written by V. Bowman in
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;; 1985. He based his work on the already existing Modula-2 mode. The
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;; file is called ada.el and is currently distributed with Emacs.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;; Lynn Slater wrote an extensive Ada mode in 1989. It consisted of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;; several files with support for dired commands and other nice
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;;; things. It is currently available from the PAL
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;;; (wuarchive.wustl.edu:/languages/ada) as ada-mode-1.06a.tar.Z.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;;; The probably very first Ada mode (called electric-ada.el) was
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;; written by Steven D. Litvintchouk and Steven M. Rosen for the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;;; Gosling Emacs. L. Slater based his development on ada.el and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;;; electric-ada.el.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;;; The current Ada mode is a complete rewrite by M. Heritsch and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;; R. Ebert. Some ideas from the ada-mode mailing list have been
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;;; added. Some of the functionality of L. Slater's mode has not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;;; (yet) been recoded in this new mode. Perhaps you prefer sticking
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;;; to his version.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;;; KNOWN BUGS / BUGREPORTS
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;; =======================
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;;; In the presence of comments and/or incorrect syntax
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;;; ada-format-paramlist produces weird results.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;; Indentation is sometimes wrong at the very beginning of the buffer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;; So please try it on different locations. If it's still wrong then
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;;; report the bug.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;;; At the moment the browsing functions are limited to the use of the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;;; separate packages "find-file.el" and "ada-xref.el" (ada-xref.el is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;;; only for GNAT users).
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;;; indenting of some tasking constructs is not yet supported.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;;; `reformat-region' sometimes generates some weird indentation.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;;;> I have the following suggestions for the function template: 1) I
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;;;> don't want it automatically assigning it a name for the return variable. I
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;;;> never want it to be called "Result" because that is nondescriptive. If you
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;;;> must define a variable, give me the ability to specify its name.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;;;>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;;;> 2) You do not provide a type for variable 'Result'. Its type is the same
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;;;> as the function's return type, which the template knows, so why force me
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;;;> to type it in?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;;;>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;;;As alwyas, different users have different tastes.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;;;It would be nice if one could configure such layout details separately
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;;;without patching the LISP code. Maybe the metalanguage used in ada-stmt.el
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;;;could be taken even further, providing the user with some nice syntax
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;;;for describing layout. Then my own hacks would survive the next
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;;;update of the package :-)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;;;By the way, there are som more quirks:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;;;1) text entered in prompt mode (*) is not converted to upper case (I have
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;;; choosen upper case for indentifiers).
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;;; (*) I would like to suggest the term "template code" instead of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;;; "pseudo code".
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;;; There are quite a few problems in the crossreferencing part. These
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;;; are partly due to errors in gnatf. One of the major bugs in
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;;; ada-xref is, that we do not wait for gnatf to rebuild the xref file.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;;; We start the job, but do not wait for finishing.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;;; LCD Archive Entry:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;;; ada-mode|Rolf Ebert|<ebert@inf.enst.fr>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;;; |Major-mode for Ada
10880
7c5fe757600b Use font-lock-maximum-decoration when setting ada-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents: 10707
diff changeset
112 ;;; |$Date: 1995/02/09 00:17:31 $|$Revision: 1.2 $|
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
10880
7c5fe757600b Use font-lock-maximum-decoration when setting ada-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents: 10707
diff changeset
115 (defconst ada-mode-version (substring "$Revision: 1.2 $" 11 -2)
7c5fe757600b Use font-lock-maximum-decoration when setting ada-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents: 10707
diff changeset
116 "$Id: ada-mode.el,v 1.2 1995/02/09 00:17:31 rms Exp simon $
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 Report bugs to: Rolf Ebert <ebert@inf.enst.fr>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;;;--------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;;; USER OPTIONS
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;;;--------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; ---- configure indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (defvar ada-indent 3
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 "*Defines the size of Ada indentation.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (defvar ada-broken-indent 2
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 "*# of columns to indent the continuation of a broken line.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (defvar ada-label-indent -4
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "*# of columns to indent a label.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (defvar ada-stmt-end-indent 0
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 "*# of columns to indent a statement end keyword in a separate line.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 Examples are 'is', 'loop', 'record', ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (defvar ada-when-indent 3
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 "*Defines the indentation for 'when' relative to 'exception' or 'case'.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (defvar ada-indent-record-rel-type 3
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "*Defines the indentation for 'record' relative to 'type' or 'use'.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defvar ada-indent-comment-as-code t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "*If non-nil, comment-lines get indented as ada-code.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (defvar ada-indent-is-separate t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 "*If non-nil, 'is separate' or 'is abstract' on a separate line are
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 indented.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (defvar ada-indent-to-open-paren t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 "*If non-nil, following lines get indented according to the innermost
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 open parenthesis.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (defvar ada-search-paren-line-count-limit 5
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 "*Search that many non-blank non-comment lines for an open parenthesis.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 Values higher than about 5 horribly slow down the indenting.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; ---- other user options
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (defvar ada-tab-policy 'indent-auto
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 "*Control behaviour of the TAB key.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 Must be one of 'indent-rigidly, 'indent-auto, 'gei, 'indent-af or 'always-tab.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 'indent-rigidly : always adds ada-indent blanks at the beginning of the line.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 'indent-auto : use indentation functions in this file.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 'gei : use David K}gedal's Generic Indentation Engine.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 'indent-af : use Gary E. Barnes' ada-format.el
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 'always-tab : do indent-relative.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (defvar ada-move-to-declaration nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 "*If non-nil, ada-move-to-start moves point to the subprog-declaration,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 not to 'begin'.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (defvar ada-spec-suffix ".ads"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 "*Suffix of Ada specification files.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (defvar ada-body-suffix ".adb"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 "*Suffix of Ada body files.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (defvar ada-language-version 'ada94
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 "*Do we program in 'ada83 or 'ada94?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (defvar ada-case-keyword 'downcase-word
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 "*downcase-word, upcase-word, ada-loose-case-word or capitalize-word
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 to adjust ada keywords case.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (defvar ada-case-identifier 'ada-loose-case-word
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 "*downcase-word, upcase-word, ada-loose-case-word or capitalize-word
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 to adjust ada identifier case.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (defvar ada-auto-case t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 "*Non-nil automatically changes casing of preceeding word while typing.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 Casing is done according to ada-case-keyword and ada-case-identifier.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (defvar ada-clean-buffer-before-saving nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 "*If non-nil, remove-trailing-spaces and untabify buffer before saving.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (defvar ada-mode-hook nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 "*List of functions to call when Ada Mode is invoked.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 This is a good place to add Ada environment specific bindings.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (defvar ada-external-pretty-print-program "aimap"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 "*External pretty printer to call from within Ada Mode.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (defvar ada-tmp-directory "/tmp/"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 "*Directory to store the temporary file for the Ada pretty printer.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (defvar ada-fill-comment-prefix "-- "
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 "*This is inserted in the first columns when filling a comment paragraph.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (defvar ada-fill-comment-postfix " --"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 "*This is inserted at the end of each line when filling a comment paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 with ada-fill-comment-paragraph postfix.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (defvar ada-krunch-args "250"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 "*Argument of gnatk8, a string containing the max number of characters.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 Set to a big number, if you dont use crunched filenames.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 ;;; ---- end of user configurable variables
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (defvar ada-mode-abbrev-table nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 "Abbrev table used in Ada mode.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (define-abbrev-table 'ada-mode-abbrev-table ())
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (defvar ada-mode-map ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 "Local keymap used for ada-mode.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (defvar ada-mode-syntax-table nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 "Syntax table to be used for editing Ada source code.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (defconst ada-83-keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 "\\<\\(abort\\|abs\\|accept\\|access\\|all\\|and\\|array\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 at\\|begin\\|body\\|case\\|constant\\|declare\\|delay\\|delta\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 digits\\|do\\|else\\|elsif\\|end\\|entry\\|exception\\|exit\\|for\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 function\\|generic\\|goto\\|if\\|in\\|is\\|limited\\|loop\\|mod\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 new\\|not\\|null\\|of\\|or\\|others\\|out\\|package\\|pragma\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 private\\|procedure\\|raise\\|range\\|record\\|rem\\|renames\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 return\\|reverse\\|select\\|separate\\|subtype\\|task\\|terminate\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 then\\|type\\|use\\|when\\|while\\|with\\|xor\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 "regular expression for looking at Ada83 keywords.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (defconst ada-94-keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 "\\<\\(abort\\|abs\\|abstract\\|accept\\|access\\|aliased\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 all\\|and\\|array\\|at\\|begin\\|body\\|case\\|constant\\|declare\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 delay\\|delta\\|digits\\|do\\|else\\|elsif\\|end\\|entry\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 exception\\|exit\\|for\\|function\\|generic\\|goto\\|if\\|in\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 is\\|limited\\|loop\\|mod\\|new\\|not\\|null\\|of\\|or\\|others\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 out\\|package\\|pragma\\|private\\|procedure\\|protected\\|raise\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 range\\|record\\|rem\\|renames\\|requeue\\|return\\|reverse\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 select\\|separate\\|subtype\\|tagged\\|task\\|terminate\\|then\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 type\\|until\\|use\\|when\\|while\\|with\\|xor\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 "regular expression for looking at Ad94 keywords.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (defvar ada-keywords ada-94-keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 "regular expression for looking at Ada keywords.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (defvar ada-ret-binding nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 "Variable to save key binding of RET when casing is activated.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (defvar ada-lfd-binding nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 "Variable to save key binding of LFD when casing is activated.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 ;;; ---- Regexps to find procedures/functions/packages
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (defvar ada-procedure-start-regexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\([a-zA-Z0-9_\\.]+\\)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 "Regexp used to find Ada procedures/functions.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (defvar ada-package-start-regexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 "^[ \t]*\\(package\\)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 "Regexp used to find Ada packages")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;;; ---- regexps for indentation functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (defvar ada-block-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 "\\<\\(begin\\|select\\|declare\\|private\\|or\\|generic\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 exception\\|loop\\|record\\|else\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 "Regexp for keywords starting ada-blocks.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (defvar ada-end-stmt-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 "\\(;\\|=>\\|\\<\\(begin\\|record\\|loop\\|select\\|do\\|\
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 exception\\|declare\\|generic\\|private\\)\\>\\)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 "Regexp of possible ends for a non-broken statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 'end' means that there has to start a new statement after these.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (defvar ada-loop-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 "\\<\\(for\\|while\\|loop\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 "Regexp for the start of a loop.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (defvar ada-subprog-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 "\\<\\(procedure\\|function\\|task\\|accept\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 "Regexp for the start of a subprogram.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ;;;-------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 ;;; functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 ;;;-------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (defun ada-create-syntax-table ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 "Create the syntax table for ada-mode."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ;; This syntax table is a merge of two syntax tables I found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ;; in the two ada modes in the old ada.el and the old
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ;; electric-ada.el. (jsl)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 ;; There still remains the problem, if the underscore '_' is a word
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 ;; constituent or not. (re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 ;; The Emacs doc clearly states that it is a symbol, and that is what most
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 ;; on the ada-mode list prefer. (re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 ;; For some functions, the syntactical meaning of '_' is temporaryly
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ;; changed to 'w'. (mh)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (setq ada-mode-syntax-table (make-syntax-table))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (set-syntax-table ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 ;; define string brackets (% is alternative string bracket)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (modify-syntax-entry ?% "\"" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (modify-syntax-entry ?\" "\"" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (modify-syntax-entry ?\# "$" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (modify-syntax-entry ?: "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (modify-syntax-entry ?\; "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (modify-syntax-entry ?& "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (modify-syntax-entry ?\| "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (modify-syntax-entry ?+ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (modify-syntax-entry ?* "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (modify-syntax-entry ?/ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (modify-syntax-entry ?= "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (modify-syntax-entry ?< "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (modify-syntax-entry ?> "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (modify-syntax-entry ?$ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (modify-syntax-entry ?\[ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (modify-syntax-entry ?\] "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (modify-syntax-entry ?\{ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (modify-syntax-entry ?\} "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (modify-syntax-entry ?. "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (modify-syntax-entry ?\\ "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (modify-syntax-entry ?\' "." ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 ;; a single hyphen is punctuation, but a double hyphen starts a comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (modify-syntax-entry ?- ". 12" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 ;; and \f and \n end a comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (modify-syntax-entry ?\f "> " ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (modify-syntax-entry ?\n "> " ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 ;; define what belongs in ada symbols
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (modify-syntax-entry ?_ "_" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 ;; define parentheses to match
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (modify-syntax-entry ?\( "()" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (modify-syntax-entry ?\) ")(" ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
360 ;;;###autoload
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (defun ada-mode ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 "Ada Mode is the major mode for editing Ada code.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 Bindings are as follows: (Note: 'LFD' is control-j.)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 Indent line '\\[ada-tab]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 Indent line, insert newline and indent the new line. '\\[newline-and-indent]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 Re-format the parameter-list point is in '\\[ada-format-paramlist]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 Indent all lines in region '\\[ada-indent-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 Call external pretty printer program '\\[ada-call-pretty-printer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 Adjust case of identifiers and keywords in region '\\[ada-adjust-case-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 Adjust case of identifiers and keywords in buffer '\\[ada-adjust-case-buffer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 Call EXTERNAL pretty printer (if you have one) '\\[ada-call-pretty-printer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 Fill comment paragraph '\\[ada-fill-comment-paragraph]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 Fill comment paragraph and justify each line '\\[ada-fill-comment-paragraph-justify]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 Fill comment paragraph, justify and append postfix '\\[ada-fill-comment-paragraph-postfix]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 Next func/proc/task '\\[ada-next-procedure]' Previous func/proc/task '\\[ada-previous-procedure]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 Next package '\\[ada-next-package]' Previous package '\\[ada-previous-package]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 Goto matching start of current 'end ...;' '\\[ada-move-to-start]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 Goto end of current block '\\[ada-move-to-end]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 Comments are handled using standard GNU Emacs conventions, including:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 Start a comment '\\[indent-for-comment]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 Comment region '\\[comment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 Uncomment region '\\[ada-uncomment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 Continue comment on next line '\\[indent-new-comment-line]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 If you use imenu.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 Display index-menu of functions & procedures '\\[imenu]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 If you use find-file.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 Switch to other file (Body <-> Spec) '\\[ff-find-other-file]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 or '\\[ff-mouse-find-other-file]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 Switch to other file in other window '\\[ada-ff-other-window]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 or '\\[ff-mouse-find-other-file-other-window]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 If you use ada-xref.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 Goto declaration: '\\[ada-point-and-xref]' on the identifier
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 or '\\[ada-goto-declaration]' with point on the identifier
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 Complete identifier: '\\[ada-complete-identifier]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 Execute Gnatf: '\\[ada-gnatf-current]'"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (kill-all-local-variables)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (make-local-variable 'require-final-newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (setq require-final-newline t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (make-local-variable 'comment-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (setq comment-start "-- ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 ;; comment end must be set because it may hold a wrong value if
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 ;; this buffer had been in another mode before. RE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (make-local-variable 'comment-end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (setq comment-end "")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (make-local-variable 'comment-start-skip) ;; used by autofill
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (setq comment-start-skip "--+[ \t]*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (make-local-variable 'indent-line-function)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (setq indent-line-function 'ada-indent-current-function)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (make-local-variable 'fill-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (setq fill-column 75)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (make-local-variable 'comment-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (setq comment-column 40)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (make-local-variable 'parse-sexp-ignore-comments)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (setq parse-sexp-ignore-comments t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (make-local-variable 'case-fold-search)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (setq case-fold-search t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
441 (make-local-variable 'fill-paragraph-function)
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
442 (setq fill-paragraph-function 'ada-fill-comment-paragraph)
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
443
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (make-local-variable 'font-lock-defaults)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (setq font-lock-defaults '(ada-font-lock-keywords nil t ((?\_ . "w"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (setq major-mode 'ada-mode)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (setq mode-name "Ada")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (setq blink-matching-paren t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (use-local-map ada-mode-map)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (if ada-mode-syntax-table
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (set-syntax-table ada-mode-syntax-table)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (ada-create-syntax-table))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (if ada-clean-buffer-before-saving
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 ;; remove all spaces at the end of lines in the whole buffer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (add-hook 'local-write-file-hooks 'ada-remove-trailing-spaces)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 ;; convert all tabs to the correct number of spaces.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (add-hook 'local-write-file-hooks 'ada-untabify-buffer)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 ;; add menu 'Ada' to the menu bar
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (ada-add-ada-menu)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (run-hooks 'ada-mode-hook)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 ;; the following has to be done after running the ada-mode-hook
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 ;; because users might want to set the values of these variable
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 ;; inside the hook (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (cond ((eq ada-language-version 'ada83)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (setq ada-keywords ada-83-keywords))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 ((eq ada-language-version 'ada94)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (setq ada-keywords ada-94-keywords)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (if ada-auto-case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (ada-activate-keys-for-case)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 ;;;--------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 ;;; Fill Comment Paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 ;;;--------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (defun ada-fill-comment-paragraph-justify ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 "Fills current comment paragraph and justifies each line as well."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (ada-fill-comment-paragraph t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (defun ada-fill-comment-paragraph-postfix ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 "Fills current comment paragraph and justifies each line as well.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 Prompts for a postfix to be appended to each line."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (ada-fill-comment-paragraph t t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (defun ada-fill-comment-paragraph (&optional justify postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 "Fills the current comment paragraph.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 If JUSTIFY is non-nil, each line is justified as well.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 If POSTFIX and JUSTIFY are non-nil, ada-fill-comment-postfix is appended
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 to each filled and justified line.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 If ada-indent-comment-as code is non-nil, the paragraph is idented."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (let ((opos (point-marker))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (end-2 nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (indent nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (ada-fill-comment-old-postfix "")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (fill-prefix nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 ;; check if inside comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (if (not (ada-in-comment-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (error "not inside comment"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 ;; prompt for postfix if wanted
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (setq ada-fill-comment-postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (read-from-minibuffer "enter new postfix string: "
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 ada-fill-comment-postfix)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 ;; prompt for old postfix to remove if necessary
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (setq ada-fill-comment-old-postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (read-from-minibuffer "enter already existing postfix string: "
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 ada-fill-comment-postfix)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ;; find limits of paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (message "filling comment paragraph ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 ;; find end of paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (while (and (looking-at "--.*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (not (looking-at "--[ \t]*$")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (back-to-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (setq end (point-marker))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (goto-char opos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 ;; find begin of paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (while (and (looking-at "--.*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (not (looking-at "--[ \t]*$")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (forward-line -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (back-to-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 ;; get indentation to calculate width for filling
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (setq indent (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (setq begin (point-marker)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 ;; delete old postfix if necessary
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (while (re-search-forward (concat ada-fill-comment-old-postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 "\n")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 end t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (replace-match "\n"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 ;; delete leading whitespace and uncomment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (while (re-search-forward "^[ \t]*--[ \t]*" end t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (replace-match "")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 ;; calculate fill width
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (setq fill-column (- fill-column indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (length ada-fill-comment-prefix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (if postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (length ada-fill-comment-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 ;; fill paragraph
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (fill-region begin (1- end) justify)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (setq fill-column (+ fill-column indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (length ada-fill-comment-prefix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (if postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (length ada-fill-comment-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 ;; find end of second last line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (goto-char end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (forward-line -2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (setq end-2 (point-marker)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 ;; re-comment and re-indent region
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (indent-to indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (insert ada-fill-comment-prefix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (while (re-search-forward "\n" (1- end-2) t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (replace-match (concat "\n" ada-fill-comment-prefix))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (indent-to indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 ;; append postfix if wanted
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (if (and justify
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 ada-fill-comment-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 ;; append postfix up to there
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (while (re-search-forward "\n" (1- end-2) t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (replace-match (concat ada-fill-comment-postfix "\n")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 ;; fill last line and append postfix
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (insert-char ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 (- fill-column
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 (current-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (length ada-fill-comment-postfix)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (insert ada-fill-comment-postfix))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 ;; delete the extra line that gets inserted somehow(??)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (goto-char (1- end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (delete-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (message "filling comment paragraph ... done")
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
634 (goto-char opos))
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
635 t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 ;;;--------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 ;;; Call External Pretty Printer ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 ;;;--------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (defun ada-call-pretty-printer ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 "Calls the external Pretty Printer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 The name is specified in ada-external-pretty-print-program. Saves the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 current buffer in a directory specified by ada-tmp-directory,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 starts the Pretty Printer as external process on that file and then
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 reloads the beautyfied program in the buffer and cleans up
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 ada-tmp-directory."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (let ((filename-with-path buffer-file-name)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (curbuf (current-buffer))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (orgpos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (mesgbuf nil) ;; for byte-compiling
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (file-path (file-name-directory buffer-file-name))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (filename-without-path (file-name-nondirectory buffer-file-name))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (tmp-file-with-directory
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (concat ada-tmp-directory
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (file-name-nondirectory buffer-file-name))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 ;; save buffer in temporary file
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (message "saving current buffer to temporary file ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (write-file tmp-file-with-directory)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (auto-save-mode nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (message "saving current buffer to temporary file ... done")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 ;; call external pretty printer program
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (message "running external pretty printer ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 ;; create a temporary buffer for messages of pretty printer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (setq mesgbuf (get-buffer-create "Pretty Printer Messages"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 ;; execute pretty printer on temporary file
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 (call-process ada-external-pretty-print-program
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 nil mesgbuf t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 tmp-file-with-directory)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 ;; display messages if there are some
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (if (buffer-modified-p mesgbuf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 ;; show the message buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (display-buffer mesgbuf t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 ;; kill the message buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 (kill-buffer mesgbuf))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (message "running external pretty printer ... done")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 ;; kill current buffer and load pretty printer output
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 ;; or restore old buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (if (y-or-n-p
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 "Really replace current buffer with pretty printer output ? ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (set-buffer-modified-p nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (kill-buffer curbuf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 (find-file tmp-file-with-directory))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (message "old buffer contents restored"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 ;; delete temporary file and restore information of current buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (delete-file tmp-file-with-directory)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (set-visited-file-name filename-with-path)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (auto-save-mode t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (goto-char orgpos)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 ;;;---------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 ;;; auto-casing
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 ;;;---------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 ;; from Philippe Waroquiers <philippe@cfmu.eurocontrol.be>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 ;; modifiedby RE and MH
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (defun ada-after-keyword-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 ;; returns t if cursor is after a keyword.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (forward-word -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 (and (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (= (point) (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (not (looking-at "_"))) ; (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (looking-at (concat ada-keywords "[^_]")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (defun ada-after-char-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 ;; returns t if after ada character "'".
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (if (> (point) 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (forward-char -2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (looking-at "'"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (defun ada-adjust-case (&optional force-identifier)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 "Adjust the case of the word before the just-typed character,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 according to ada-case-keyword and ada-case-identifier
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 If FORCE-IDENTIFIER is non-nil then also adjust keyword as
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 identifier." ; (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (forward-char -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (if (and (> (point) 1) (not (or (ada-in-string-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (ada-in-comment-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (ada-after-char-p))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (if (eq (char-syntax (char-after (1- (point)))) ?w)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (not force-identifier) ; (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (ada-after-keyword-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (funcall ada-case-keyword -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 (funcall ada-case-identifier -1))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (forward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (defun ada-adjust-case-interactive (arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 (let ((lastk last-command-char))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 (cond ((or (eq lastk ?\n)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (eq lastk ?\r))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 ;; horrible kludge
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (insert " ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (ada-adjust-case)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 ;; horrible dekludge
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (delete-backward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 ;; some special keys and their bindings
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 ((eq lastk ?\n)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (funcall ada-lfd-binding))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 ((eq lastk ?\r)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (funcall ada-ret-binding))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 ((eq lastk ?\C-i) (ada-tab))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 ((self-insert-command (prefix-numeric-value arg))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 ;; if there is a keyword in front of the underscore
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 ;; then it should be part of an identifier (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 (if (eq lastk ?_)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 (ada-adjust-case t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (ada-adjust-case))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 (defun ada-activate-keys-for-case ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 ;; save original keybindings to allow swapping ret/lfd
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 ;; when casing is activated
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 ;; the 'or ...' is there to be sure that the value will not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 ;; be changed again when ada-mode is called more than once (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 (or ada-ret-binding
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 (setq ada-ret-binding (key-binding "\C-M")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (or ada-lfd-binding
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (setq ada-lfd-binding (key-binding "\C-j")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 ;; call case modifying function after certain keys.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (mapcar (function (lambda(key) (define-key
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 ada-mode-map
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 (char-to-string key)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 'ada-adjust-case-interactive)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 '( ?` ?~ ?! ?@ ?# ?$ ?% ?^ ?& ?* ?( ?) ?- ?= ?+ ?[ ?{ ?] ?}
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 ?_ ?\\ ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?? ?/ ?\n 32 ?\r )))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 ;; deleted ?\t from above list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 ;; added by MH
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 (defun ada-loose-case-word (&optional arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 "Capitalizes the first and the letters following _
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 ARG is ignored, it's there to fit the standard casing functions' style."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (let ((pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (first t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 (skip-chars-backward "a-zA-Z0-9_")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 (while (or first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 (search-forward "_" pos t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (and first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (setq first nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (insert-char (upcase (following-char)) 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 (delete-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 (goto-char pos)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 ;; added by MH
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (defun ada-adjust-case-region (from to)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 "Adjusts the case of all identifiers and keywords in the region.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 ATTENTION: This function might take very long for big regions !"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (keywordp nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 (reldiff nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 (goto-char to)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 ;; loop: look for all identifiers and keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 (while (re-search-backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 "[^a-zA-Z0-9_]\\([a-zA-Z0-9_]+\\)[^a-zA-Z0-9_]"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 from
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 ;; print status message
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (setq reldiff (- (point) from))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (message (format "adjusting case ... %5d characters left"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (- (point) from)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 ;; do nothing if it is a string or comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 (ada-in-string-or-comment-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 ;; get the identifier or keyword
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (setq begin (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 (setq keywordp (looking-at (concat ada-keywords "[^_]")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (skip-chars-forward "a-zA-Z0-9_")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 ;; casing according to user-option
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 (if keywordp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 (funcall ada-case-keyword -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 (funcall ada-case-identifier -1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 (goto-char begin))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 (message "adjusting case ... done"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 ;; added by MH
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (defun ada-adjust-case-buffer ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 "Adjusts the case of all identifiers and keywords in the whole buffer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 ATTENTION: This function might take very long for big buffers !"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 (ada-adjust-case-region (point-min) (point-max)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 ;;;------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 ;;; Format Parameter Lists ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 ;;;------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (defun ada-format-paramlist ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 "Re-formats a parameter-list.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 ATTENTION: 1) Comments inside the list are killed !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 2) If the syntax is not correct (especially, if there are
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 semicolons missing), it can get totally confused !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 In such a case, use 'undo', correct the syntax and try again."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (delend nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (paramlist nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 ;; ATTENTION: modify sntax-table temporary !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 (modify-syntax-entry ?_ "w")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 ;; check if really inside parameter list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (or (ada-in-paramlist-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 (error "not in parameter list"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 ;; find start of current parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 "procedure\\|function\\|body\\|package\\|task\\|entry\\|accept"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 "\\)\\>") t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 (ada-search-ignore-string-comment "(" nil nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (backward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 (setq begin (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 ;; find end of parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 (forward-sexp 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 (setq delend (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 (delete-char -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 ;; find end of last parameter-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 (ada-search-ignore-string-comment "[^ \t\n]" t nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 (setq end (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 ;; build a list of all elements of the parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 (setq paramlist (ada-scan-paramlist (1+ begin) end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 ;; delete the original parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (delete-region begin (1- delend))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 ;; insert the new parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (ada-insert-paramlist paramlist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 ;; restore syntax-table
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (modify-syntax-entry ?_ "_")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (defun ada-scan-paramlist (begin end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 ;; Scans a parameter-list between BEGIN and END and returns a list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 ;; of its contents.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 ;; The list has the following format:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 ;; Name of Param in? out? accept? Name of Type Default-Exp or nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 ;; ( ('Name_Param_1' t nil t Type_Param_1 ':= expression')
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 ;; ('Name_Param_2' nil nil t Type_Param_2 nil) )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (let ((paramlist (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (param (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (notend t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (apos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (epos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (semipos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 ;; loop until end of last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 (while notend
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 ;; find first character of parameter-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 (setq apos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 ;; find last character of parameter-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 (if (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 (ada-search-ignore-string-comment "[ \t\n]*;" nil end t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 (setq epos (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (setq semipos (cdr match-cons)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 (setq epos end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 ;; read name(s) of parameter(s)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 (looking-at "\\([a-zA-Z0-9_, \t\n]*[a-zA-Z0-9_]\\)[ \t\n]*:[^=]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 (setq param (list (buffer-substring (match-beginning 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 (match-end 1))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 (ada-search-ignore-string-comment ":" nil epos t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 ;; look for 'in'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 (setq apos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 (consp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 (ada-search-ignore-string-comment "\\<in\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 t)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 ;; look for 'out'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 (consp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 (ada-search-ignore-string-comment "\\<out\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 t)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 ;; look for 'accept'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (consp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 (ada-search-ignore-string-comment "\\<accept\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 t)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 ;; skip 'in'/'out'/'accept'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 (while (looking-at "\\<\\(in\\|out\\|accept\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 (ada-goto-next-non-ws))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 ;; read type of parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 (looking-at "\\<[a-zA-Z0-9_\\.]+\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 (buffer-substring (match-beginning 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 (match-end 0)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 ;; read default-expression, if there is one
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 (goto-char (setq apos (match-end 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 (setq param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 (append param
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 (if (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 (ada-search-ignore-string-comment ":="
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 epos
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 (buffer-substring (car match-cons)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 epos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 ;; add this parameter-declaration to the list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 (setq paramlist (append paramlist (list param)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 ;; check if it was the last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 (if (eq epos end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 (setq notend nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 (goto-char semipos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 ) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 (reverse paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 (defun ada-insert-paramlist (paramlist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 ;; Inserts a formatted PARAMLIST in the buffer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 ;; See doc of ada-scan-paramlist for the format.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 (let ((i (length paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 (parlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 (typlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 (temp 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 (inp nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 (outp nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 (acceptp nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 (column nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 (orgpoint 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 (firstcol nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 (while (not (zerop i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 (setq i (1- i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 ;; get max length of parameter-name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 (setq parlen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 (if (<= parlen (setq temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 (length (nth 0 (nth i paramlist)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 parlen))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 ;; get max length of type-name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 (setq typlen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 (if (<= typlen (setq temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 (length (nth 4 (nth i paramlist)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 temp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 typlen))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 ;; is there any 'in' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 (setq inp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 (or inp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 (nth 1 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 ;; is there any 'out' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 (setq outp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 (or outp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 (nth 2 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 ;; is there any 'accept' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 (setq acceptp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 (or acceptp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 (nth 3 (nth i paramlist))))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 ;; does paramlist already start on a separate line ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 (re-search-backward "^.\\|[^ \t]" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 (looking-at "^."))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 ;; yes => re-indent it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 ;; no => insert newline and indent it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 (newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 (delete-horizontal-space)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 (setq orgpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 (setq column (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 (funcall (ada-indent-function) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 (indent-to column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 (insert "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 (setq firstcol (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 (setq i (length paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 (while (not (zerop i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 (setq i (1- i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 (setq column firstcol)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 ;; insert parameter-name, space and colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 (insert (nth 0 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 (indent-to (+ column parlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 (insert ": ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 (setq column (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 ;; insert 'in' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 (if (nth 1 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 (insert "in ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (or inp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 acceptp)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 (insert " ")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 ;; insert 'out' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (if (nth 2 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 (insert "out ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 (or outp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 acceptp)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 (insert " ")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 ;; insert 'accept'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 (if (nth 3 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 (insert "accept "))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 (setq column (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 ;; insert type-name and, if necessary, space and default-expression
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 (insert (nth 4 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 (if (nth 5 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 (indent-to (+ column typlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 (insert (nth 5 (nth i paramlist)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 ;; check if it was the last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 (if (not (zerop i))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 ;; no => insert ';' and newline and indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 (insert ";")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 (newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 (indent-to firstcol))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 ;; yes
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 (insert ")"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 ) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 ;; if anything follows, except semicolon:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 ;; put it in a new line and indent it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 (if (not (looking-at "[ \t]*[;\n]"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 (ada-indent-newline-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 ;;;----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 ;;; Move To Matching Start/End ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 ;;;----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 (defun ada-move-to-start ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 "Moves point to the matching start of the current end ... around point."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 (let ((pos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 ;; ATTENTION: modify sntax-table temporary !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 (modify-syntax-entry ?_ "w")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 (message "searching for block start ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 ;; do nothing if in string or comment or not on 'end ...;'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 ;; or if an error occurs during processing
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 (ada-in-string-or-comment-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 (and (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 (or (looking-at "[ \t]*\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265 (backward-word 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 (or (looking-at "[ \t]*\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 (backward-word 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 (or (looking-at "[ \t]*\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 (error "not on end ...;")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271 (setq pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 ;; on 'begin' => go on, according to user option
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 ada-move-to-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 (looking-at "\\<begin\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 (ada-goto-matching-decl-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 (setq pos (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 ) ; end of save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 ;; now really move to the found position
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 (goto-char pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 (message "searching for block start ... done")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 ;; restore syntax-table
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 (modify-syntax-entry ?_ "_")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 (defun ada-move-to-end ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 "Moves point to the matching end of the current block around point.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 Moves to 'begin' if in a declarative part."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (let ((pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 (decstart nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 (packdecl nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 ;; ATTENTION: modify sntax-table temporary !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 (modify-syntax-entry ?_ "w")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (message "searching for block end ...")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 ;; directly on 'begin'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 (looking-at "\\<begin\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 (ada-goto-matching-end 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 ;; on first line of defun declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 (and (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 (looking-at "\\<function\\>\\|\\<procedure\\>" )))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 (ada-search-ignore-string-comment "\\<begin\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 ;; on first line of task declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 (and (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 (looking-at "\\<task\\>" )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 (ada-search-ignore-string-comment "[^ \n\t]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 (not (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 (looking-at "\\<body\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (ada-search-ignore-string-comment "\\<begin\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 ;; accept block start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 (and (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (looking-at "\\<accept\\>" )))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 (ada-goto-matching-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 ;; package start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (and (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 (looking-at "\\<package\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 (ada-goto-matching-end 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 ;; inside a 'begin' ... 'end' block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 (ada-goto-matching-decl-start t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 (ada-search-ignore-string-comment "\\<begin\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 ;; (hopefully ;-) everything else
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 (ada-goto-matching-end 1)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 (setq pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348 ) ; end of save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 ;; now really move to the found position
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (goto-char pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352 (message "searching for block end ... done")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 ;; restore syntax-table
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (modify-syntax-entry ?_ "_")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 ;;;-----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 ;;; Functions For Indentation ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 ;;;-----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 ;; ---- main functions for indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 (defun ada-indent-region (beg end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 "Indents the region using ada-indent-current on each line."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (goto-char beg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 ;; catch errors while indenting
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 (condition-case err
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 (while (< (point) end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 (message (format "indenting ... %4d lines left"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 (count-lines (point) end)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376 (forward-line 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 ;; show line number where the error occured
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 (error
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (error (format "line %d: %s"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 (1+ (count-lines (point-min) (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 err) nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382 (message "indenting ... done"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385 (defun ada-indent-newline-indent ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386 "Indents the current line, inserts a newline and then indents the new line."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 (interactive "*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 (let ((column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 (orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 (ada-indent-current)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 (delete-horizontal-space)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (setq orgpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 ;; ATTENTION: modify syntax-table temporary !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 (modify-syntax-entry ?_ "w")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 (setq column (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 (funcall (ada-indent-function) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 ;; restore syntax-table
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 (modify-syntax-entry ?_ "_")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 (indent-to column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 ;; The following is needed to ensure that indentation will still be
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 ;; correct if something follows behind point when typing LFD
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 ;; For example: Imagine point to be there (*) when LFD is typed:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 ;; while cond loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 ;; null; *end loop;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 ;; Result without the following statement would be:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 ;; while cond loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 ;; null;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 ;; *end loop;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 ;; You would then have to type TAB to correct it.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 ;; If that doesn't bother you, you can comment out the following
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 ;; statement to speed up indentation a LITTLE bit.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (if (not (looking-at "[ \t]*$"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 (ada-indent-current))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 (defun ada-indent-current ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 "Indents current line as Ada code.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 This works by two steps:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 1) It moves point to the end of the previous code-line.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 Then it calls the function to calculate the indentation for the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1434 following line as if a newline would be inserted there.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 The calculated column # is saved and the old position of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 is restored.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 2) Then another function is called to calculate the indentation for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 the current line, based on the previously calculated column #."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1442 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443 ;; ATTENTION: modify sntax-table temporary !
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1444 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1445 (modify-syntax-entry ?_ "w")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 (let ((line-end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (orgpoint (point-marker))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (cur-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 (prev-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 (prevline t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 ;; first step
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 (if (ada-goto-prev-nonblank-line t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 ;; we are not in the first accessible line in the buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 (setq line-end (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (setq prev-indent (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 (funcall (ada-indent-function) line-end))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (setq prevline nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 (if prevline
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 ;; we are not in the first accessible line in the buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 ;; second step
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 (setq cur-indent (ada-get-current-indent prev-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 (delete-horizontal-space)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 (indent-to cur-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 ;; restore position of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (goto-char orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (if (< (current-column) (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 (back-to-indentation)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 ;; restore syntax-table
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 (modify-syntax-entry ?_ "_"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 (defun ada-get-current-indent (prev-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 ;; Returns the column # to indent the current line to.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 ;; PREV-INDENT is the indentation resulting from the previous lines.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 (let ((column nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 ;; in open parenthesis, but not in parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 ada-indent-to-open-paren
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 (not (ada-in-paramlist-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (setq column (ada-in-open-paren-p)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510 ;; check if we have something like this (Table_Component_Type =>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 ;; Source_File_Record,)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (if (and (ada-search-ignore-string-comment "[^ \t]" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 (looking-at "\n")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 (ada-search-ignore-string-comment "[^ \t\n]" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 (looking-at ">"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 (setq column (+ ada-broken-indent column))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 ;; end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 ((looking-at "\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 ;; found 'loop' => skip back to 'while' or 'for'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529 ;; if 'loop' is not on a separate line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 (looking-at "\\<loop\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (not (looking-at "\\<loop\\>"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 ada-loop-start-re t nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 (not (looking-at "\\<loop\\>"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 (goto-char (car match-cons))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 ;; exception
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 ((looking-at "\\<exception\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 ;; when
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 ((looking-at "\\<when\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 (+ (current-indentation) ada-when-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 ;; else
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 ((looking-at "\\<else\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 (looking-at "\\<or\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (ada-goto-matching-start 1 nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 (current-indentation))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 ;; elsif
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 ((looking-at "\\<elsif\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 (ada-goto-matching-start 1 nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 ;; then
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 ((looking-at "\\<then\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 (looking-at "\\<and\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 (ada-search-ignore-string-comment "\\<elsif\\>\\|\\<if\\>" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 (+ (current-indentation) ada-stmt-end-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 ;; loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 ((looking-at "\\<loop\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 (setq pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 (if (looking-at "\\<loop\\>\\|\\<if\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599 (if (not (looking-at ada-loop-start-re))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 (ada-search-ignore-string-comment ada-loop-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 nil pos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602 (if (looking-at "\\<loop\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 (+ (current-indentation) ada-stmt-end-indent))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606 ;; begin
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608 ((looking-at "\\<begin\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 (if (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 (current-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 (message "no matching declaration start")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 prev-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 ;; is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 ((looking-at "\\<is\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620 ada-indent-is-separate
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623 (ada-goto-next-non-ws (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626 (looking-at "\\<abstract\\>\\|\\<separate\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632 (+ (current-indentation) ada-stmt-end-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1633 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 ;; record
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 ((looking-at "\\<record\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 "\\<\\(type\\|use\\)\\>" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640 (if (looking-at "\\<use\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1641 (ada-search-ignore-string-comment "\\<for\\>" t nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1642 (+ (current-indentation) ada-indent-record-rel-type)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1643 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1644 ;; or as statement-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1645 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646 ((ada-looking-at-semi-or)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1647 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1648 (ada-goto-matching-start 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1649 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1650 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1651 ;; private as statement-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1652 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1653 ((ada-looking-at-semi-private)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1654 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1655 (ada-goto-matching-decl-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1656 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1658 ;; new/abstract/separate
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1659 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1660 ((looking-at "\\<\\(new\\|abstract\\|separate\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661 (- prev-indent ada-indent (- ada-broken-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1662 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 ;; return
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 ((looking-at "\\<return\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 (forward-sexp -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 (if (and (looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 (backward-sexp 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 (looking-at "\\<function\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 (1+ (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673 prev-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 ;; do
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 ((looking-at "\\<do\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 (+ (current-indentation) ada-stmt-end-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 ;; package/function/procedure
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684 ((and (looking-at "\\<\\(package\\|function\\|procedure\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1685 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1687 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1688 (looking-at "\\<\\(package\\|function\\|procedure\\)\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690 ;; look for 'generic'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691 (if (and (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 (looking-at "generic"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693 (current-column)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1694 prev-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1695 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1696 ;; label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1697 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 ((looking-at "\\<[a-zA-Z0-9_]+[ \t\n]*:[^=]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (+ prev-indent ada-label-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 ;; identifier and other noindent-statements
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 ((looking-at "\\<[a-zA-Z0-9_]+[ \t\n]*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706 prev-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 ;; beginning of a parameter list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 ((looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711 prev-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713 ;; end of a parameter list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1715 ((looking-at ")")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1716 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1717 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1718 (backward-sexp 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 (current-column)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 ;; comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1722 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1723 ((looking-at "--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1724 (if ada-indent-comment-as-code
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1725 prev-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1727 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1728 ;; unknown syntax - maybe this should signal an error ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1729 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1730 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731 prev-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1733
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1734 (defun ada-indent-function (&optional nomove)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735 ;; Returns the function to calculate the indentation for the current
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736 ;; line according to the previous statement, ignoring the contents
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1737 ;; of the current line after point. Moves point to the beginning of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1738 ;; the current statement, if NOMOVE is nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1739
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 (let ((orgpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 (func nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742 (stmt-start nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744 ;; inside a parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 (if (ada-in-paramlist-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1747 (setq func 'ada-get-indent-paramlist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1748 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1750 ;; move to beginning of current statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 (if (not nomove)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 (setq stmt-start (ada-goto-stmt-start)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 ;; no beginning found => don't change indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 (eq orgpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1759 (not nomove))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1760 (setq func 'ada-get-indent-nochange)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 ada-indent-to-open-paren
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 (ada-in-open-paren-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 (setq func 'ada-get-indent-open-paren))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 ((looking-at "\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770 (setq func 'ada-get-indent-end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 ((looking-at ada-loop-start-re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 (setq func 'ada-get-indent-loop))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 ((looking-at ada-subprog-start-re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 (setq func 'ada-get-indent-subprog))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 ((looking-at "\\<package\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 (setq func 'ada-get-indent-subprog)) ; maybe it needs a
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1780 ; special function
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 ; sometimes ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 ((looking-at ada-block-start-re)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1784 (setq func 'ada-get-indent-block-start))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1785 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 ((looking-at "\\<type\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 (setq func 'ada-get-indent-type))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 ((looking-at "\\<if\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 (setq func 'ada-get-indent-if))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 ((looking-at "\\<elsif\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (setq func 'ada-get-indent-if)) ; maybe it needs a special
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 ; function sometimes ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 ((looking-at "\\<case\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 (setq func 'ada-get-indent-case))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 ((looking-at "\\<when\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1800 (setq func 'ada-get-indent-when))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 ((looking-at "--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 (setq func 'ada-get-indent-comment))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 ((looking-at "[a-zA-Z0-9_]+[ \t\n]*:[^=]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (setq func 'ada-get-indent-label))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (setq func 'ada-get-indent-noindent))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1810
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 func))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 ;; ---- functions to return indentation for special cases
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1815
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (defun ada-get-indent-open-paren (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1817 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 ;; Assumes point to be behind an open paranthesis not yet closed.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1819 (ada-in-open-paren-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 (defun ada-get-indent-nochange (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 ;; Returns the indentation (column #) of the current line.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825 (forward-line -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 (defun ada-get-indent-paramlist (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 ;; Assumes point to be inside a parameter-list.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833 (ada-search-ignore-string-comment "[^ \t\n]" t nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1835 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836 ;; in front of the first parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838 ((looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840 (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 ;; in front of another parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 ((looking-at ";")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1846 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1847 (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849 ;; inside a parameter declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (+ (current-column) ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1857 (defun ada-get-indent-end (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1858 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859 ;; Assumes point to be at the beginning of an end-statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1860 ;; Therefore it has to find the corresponding start. This can be a little
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1861 ;; slow, if it has to search through big files with many nested blocks.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1862 ;; Signals an error if the corresponding block-start doesn't match.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1863 (let ((defun-name nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1864 (indent nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1865 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1866 ;; is the line already terminated by ';' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1867 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1868 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1869 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1870 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1871 ;; yes, look what's following 'end'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1872 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1873 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1874 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1875 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1876 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1877 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 ;; loop/select/if/case/record/select
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1879 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1880 ((looking-at "\\<\\(loop\\|select\\|if\\|case\\|record\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1881 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1882 (ada-check-matching-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1883 (buffer-substring (match-beginning 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884 (match-end 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1885 (if (looking-at "\\<\\(loop\\|record\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1886 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1887 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1888 (ada-goto-stmt-start)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1889 ;; a label ? => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1890 (if (looking-at "[a-zA-Z0-9_]+[ \n\t]+:")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1891 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1892 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1893 (ada-goto-next-non-ws)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1894 ;; really looking-at the right thing ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1895 (or (looking-at (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1896 "loop\\|select\\|if\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1897 "record\\|while\\|type\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1898 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1899 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1900 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1901 "loop\\|select\\|if\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1902 "record\\|while\\|type\\)\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1903 (backward-word 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1904 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1905 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1906 ;; a named block end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1907 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 ((looking-at "[a-zA-Z0-9_]+")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 (setq defun-name (buffer-substring (match-beginning 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 (match-end 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912 (ada-goto-matching-start 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 (ada-check-defun-name defun-name)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1915 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916 ;; a block-end without name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 ((looking-at ";")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 (ada-goto-matching-start 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 (if (looking-at "\\<begin\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 (setq indent (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924 (if (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1925 (current-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928 ;; anything else - should maybe signal an error ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1929 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1930 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 (+ (current-indentation) ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 (+ (current-indentation) ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 (defun ada-get-indent-case (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1938 ;; Assumes point to be at the beginning of an case-statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939 (let ((cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 (match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 (opos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944 ;; case..is..when..=>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 "[ \t\n]+=>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (if (not (ada-search-ignore-string-comment "\\<when\\>" t opos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952 (error "missing 'when' between 'case' and '=>'"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 (+ (current-indentation) ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955 ;; case..is..when
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1956 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1957 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1958 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1959 "\\<when\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 (goto-char (cdr match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1961 (+ (current-indentation) ada-broken-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1962 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1963 ;; case..is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1964 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967 "\\<is\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1968 (+ (current-indentation) ada-when-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 ;; incomplete case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1972 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1973 (+ (current-indentation) ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1974
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1975
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 (defun ada-get-indent-when (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 ;; Assumes point to be at the beginning of an when-statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1979 (let ((cur-indent (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1980 (if (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1981 "[ \t\n]+=>" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1982 (+ cur-indent ada-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1983 (+ cur-indent ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1985
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 (defun ada-get-indent-if (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 ;; Assumes point to be at the beginning of an if-statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 (let ((cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1992 ;; if..then ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1994 (if (ada-search-but-not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1995 "\\<then\\>" "\\<and\\>[ \t\n]+\\<then\\>" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1996
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1997 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1998 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1999 ;; 'then' first in separate line ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2000 ;; => indent according to 'then'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2001 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2002 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2003 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2004 (looking-at "\\<then\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 (setq cur-indent (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2006 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2008 ;; something follows 'then' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010 (if (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2012 "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2013 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2014 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2015 (+ ada-indent
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 (- cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2017 (funcall (ada-indent-function t) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2018
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2019 (+ cur-indent ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2020
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2021 (+ cur-indent ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2022
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024 (defun ada-get-indent-block-start (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2025 ;; Returns the indentation (column #) for the new line after
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2026 ;; ORGPOINT. Assumes point to be at the beginning of a block start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2027 ;; keyword.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2028 (let ((cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2029 (pos nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2032 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 (setq pos (car (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 "[^ \t\n]" nil orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035 (goto-char pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2036 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2037 (funcall (ada-indent-function t) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2038 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 ;; nothing follows the block-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2040 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2042 (+ (current-indentation) ada-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2043
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2044
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045 (defun ada-get-indent-subprog (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2047 ;; Assumes point to be at the beginning of a subprog-/package-declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2048 (let ((match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2049 (cur-indent (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2050 (foundis nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2051 (addind 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2052 (fstart (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2053 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2054 ;; is there an 'is' in front of point ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2055 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2056 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2057 (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2058 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2059 "\\<is\\>\\|\\<do\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2061 ;; yes, then skip to its end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2062 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2063 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2064 (setq foundis t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2065 (goto-char (cdr match-cons)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2066 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2067 ;; no, then goto next non-ws, if there is one in front of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2068 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2069 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2070 (if (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2071 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2072 (goto-char orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2073
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2074 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2075 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2076 ;; nothing follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2077 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2078 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2079 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2080 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2081 (not (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2082 "[^ \t\n]" nil orgpoint t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2083 (+ cur-indent ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2084 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2085 ;; is abstract/separate/new ...
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2086 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2087 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2088 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2089 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2090 (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2091 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2092 "\\<\\(separate\\|new\\|abstract\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2093 nil orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2094 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2095 (ada-search-ignore-string-comment (concat ada-subprog-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2096 "\\|\\<package\\>") t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2097 (ada-get-indent-noindent orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2098 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2099 ;; something follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2100 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2101 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2103 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2104 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2105 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 (funcall (ada-indent-function t) orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2107 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 ;; no 'is' but ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112 cur-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2113 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 ;; no 'is' or ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2115 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 (+ cur-indent ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2118
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2119
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120 (defun ada-get-indent-noindent (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 ;; Assumes point to be at the beginning of a 'noindent statement'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2125 (current-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2126 (+ (current-indentation) ada-broken-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2127
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2128
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2129 (defun ada-get-indent-label (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2131 ;; Assumes point to be at the beginning of a label or variable declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 ;; Checks the context to decide if it's a label or a variable declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2133 ;; This check might be a bit slow.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2134 (let ((match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 (cur-indent (current-indentation)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 (goto-char (cdr (ada-search-ignore-string-comment ":")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2137 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2138 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2139 ;; loop label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2140 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2143 ada-loop-start-re nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2144 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (ada-get-indent-loop orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2147 ;; declare label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 "\\<declare\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2154 (+ (current-indentation) ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 ;; complete statement following colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2157 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2158 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2159 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2160 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2161 cur-indent ; variable-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162 (- cur-indent ada-label-indent))) ; label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 ;; broken statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2166 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2168 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2169 (+ cur-indent ada-broken-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2170 (+ cur-indent ada-broken-indent (- ada-label-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2171 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2172 ;; nothing follows colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2173 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2174 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2175 (if (ada-in-decl-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 (+ cur-indent ada-broken-indent) ; variable-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177 (- cur-indent ada-label-indent)))))) ; label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2180 (defun ada-get-indent-loop (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2181 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 ;; Assumes point to be at the beginning of a loop statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2183 ;; or (unfortunately) also a for ... use statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2184 (let ((match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2185 (pos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2186 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2188 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189 ;; statement complete
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2192 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2193 (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2195 ;; simple loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197 ((looking-at "loop\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2198 (ada-get-indent-block-start orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2199
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2200 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201 ;; 'for'- loop (or also a for ... use statement)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 ((looking-at "for\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 ;; for ... use
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2208 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2211 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2212 (not (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2213 (not (zerop (skip-chars-forward "_a-zA-Z0-9'")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2214 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2215 (not (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2216 (looking-at "\\<use\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2217 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2218 ;; check if there is a 'record' before point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2220 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 "\\<record\\>" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2224 (if match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225 (goto-char (car match-cons)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2228 ;; for..loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2229 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2230 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2231 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2232 "\\<loop\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2233 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2234 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2235 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2236 ;; otherwise to 'for'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2237 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2238 (if (not (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2239 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2240 (looking-at "\\<loop\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2241 (goto-char pos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2242 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2243 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2244 ;; for-statement is broken
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2246 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2247 (+ (current-indentation) ada-broken-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2248
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2249 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2250 ;; 'while'-loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 ((looking-at "while\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 ;; while..loop ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 "\\<loop\\>" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 ;; otherwise to 'while'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 (if (not (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268 (looking-at "\\<loop\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269 (goto-char pos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272 (+ (current-indentation) ada-broken-indent))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (defun ada-get-indent-type (orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 ;; Returns the indentation (column #) for the new line after ORGPOINT.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 ;; Assumes point to be at the beginning of a type statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 (let ((match-dat nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2281 ;; complete record declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2282 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 (setq match-dat (ada-search-ignore-string-comment "\\<end\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2287 orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 (looking-at "\\<record\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2292 (looking-at ";")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 ;; record type
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 (setq match-dat (ada-search-ignore-string-comment "\\<record\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2300 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301 orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2302 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2304 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305 ;; complete type declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2306 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 (ada-search-ignore-string-comment ";" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 (current-indentation))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2310 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2311 ;; type ... is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2312 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2313 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2314 (ada-search-ignore-string-comment "\\<is\\>" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2315 (+ (current-indentation) ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2316 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 ;; broken statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2318 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2319 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320 (+ (current-indentation) ada-broken-indent)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2321
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2322
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2323 ;;; ---- support-functions for indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2325 ;;; ---- searching and matching
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2326
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2327 (defun ada-goto-stmt-start (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2328 ;; Moves point to the beginning of the statement that point is in or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 ;; after. Returns the new position of point. Beginnings are found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 ;; by searching for 'ada-end-stmt-re' and then moving to the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 ;; following non-ws that is not a comment. LIMIT is actually not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2332 ;; used by the indentation functions.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2333 (let ((match-dat nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334 (orgpoint (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2335
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2336 (setq match-dat (ada-search-prev-end-stmt limit))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 (if match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339 ;; found a previous end-statement => check if anything follows
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2341 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 (if (not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 (goto-char (cdr match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 "[^ \t\n]" nil orgpoint)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2348 ;; nothing follows => it's the end-statement directly in
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2349 ;; front of point => search again
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2350 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2351 (setq match-dat (ada-search-prev-end-stmt limit)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2352 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2353 ;; if found the correct end-stetement => goto next non-ws
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 (if match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356 (goto-char (cdr match-dat)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357 (ada-goto-next-non-ws))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2358
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360 ;; no previous end-statement => we are at the beginning of the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361 ;; accessible part of the buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2364 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 ;; skip to the very first statement, if there is one
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 (if (setq match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2369 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 "[^ \t\n]" nil orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2371 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 (goto-char orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2373
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375 (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2377
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378 (defun ada-search-prev-end-stmt (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2379 ;; Moves point to previous end-statement. Returns a cons cell whose
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380 ;; car is the beginning and whose cdr the end of the match.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2381 ;; End-statements are defined by 'ada-end-stmt-re'. Checks for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2382 ;; certain keywords if they follow 'end', which means they are no
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2383 ;; end-statement there.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2384 (let ((match-dat nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2385 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2386 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2387 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2388 ;; search until found or beginning-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2389 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2390 (while
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2391 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2392 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2393 (setq match-dat (ada-search-ignore-string-comment ada-end-stmt-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2394 t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2395 limit)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2396
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2397 (goto-char (car match-dat))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2398
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2399 (if (not (ada-in-open-paren-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2400 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2401 ;; check if there is an 'end' in front of the match
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 (if (not (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2404 (looking-at "\\<\\(record\\|loop\\|select\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2405 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2406 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2407 (looking-at "\\<end\\>"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2408 (setq found t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 (backward-word 1)))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2412 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2413 match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2416
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2417 (defun ada-goto-next-non-ws (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2418 ;; Skips whitespaces, newlines and comments to next non-ws
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2419 ;; character. Signals an error if there is no more such character
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2420 ;; and limit is nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2421 (let ((match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2422 (setq match-cons (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2423 "[^ \t\n]" nil limit t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 (if match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2426 (if (not limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 (error "no more non-ws")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2429
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 (defun ada-goto-stmt-end (&optional limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432 ;; Moves point to the end of the statement that point is in or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 ;; before. Returns the new position of point or nil if not found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2434 (if (ada-search-ignore-string-comment ada-end-stmt-re nil limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 (point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2437
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2439 (defun ada-goto-previous-word ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2440 ;; Moves point to the beginning of the previous word of ada-code.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 ;; Returns the new position of point or nil if not found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442 (let ((match-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2443 (orgpoint (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2444 (if (setq match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2445 (ada-search-ignore-string-comment "[^ \t\n]" t nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2446 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2447 ;; move to the beginning of the word found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2448 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 (goto-char (cdr match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2451 (skip-chars-backward "_a-zA-Z0-9")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2452 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2454 ;; if not found, restore old position of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2455 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2456 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457 (goto-char orgpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2458 'nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461 (defun ada-check-matching-start (keyword)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 ;; Signals an error if matching block start is not KEYWORD.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 ;; Moves point to the matching block start.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 (ada-goto-matching-start 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465 (if (not (looking-at (concat "\\<" keyword "\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466 (error (concat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 "matching start is not '"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2468 keyword "'"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2469
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2470
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2471 (defun ada-check-defun-name (defun-name)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472 ;; Checks if the name of the matching defun really is DEFUN-NAME.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 ;; Assumes point to be already positioned by 'ada-goto-matching-start'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474 ;; Moves point to the beginning of the declaration.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2477 ;; 'accept' or 'package' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 (if (not (looking-at "\\<\\(accept\\|package\\|task\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2480 (ada-goto-matching-decl-start))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 ;; 'begin' of 'procedure'/'function'/'task' or 'declare'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2485 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486 ;; a named 'declare'-block ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 (if (looking-at "\\<declare\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2491 ;; no, => 'procedure'/'function'/'task'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494 (forward-word 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2495 (backward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497 ;; skip 'body' or 'type'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 (if (looking-at "\\<\\(body\\|type\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 (forward-word 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 (forward-sexp 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502 (backward-sexp 1)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2503 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 ;; should be looking-at the correct name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (if (not (looking-at (concat "\\<" defun-name "\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (error
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 (concat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 "matching defun has different name: "
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 (buffer-substring
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 (point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 (forward-sexp 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 (point))))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2516
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 (defun ada-goto-matching-decl-start (&optional noerror nogeneric)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2518 ;; Moves point to the matching declaration start of the current 'begin'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2519 ;; If NOERROR is non-nil, it only returns nil if no match was found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2520 (let ((nest-count 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2521 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2522 (first t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2523 (flag nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2524 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2527 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 (not (zerop nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2529 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2530 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531 "is\\|separate\\|end\\|declare\\|new\\|begin\\|generic"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2532 "\\)\\>") t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2534 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2535 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2536 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2538 ((looking-at "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2539 (ada-goto-matching-start 1 noerror)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2540 (if (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2541 (looking-at "begin"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2542 (setq nest-count (1+ nest-count))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2543 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2544 ((looking-at "declare\\|generic")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545 (setq nest-count (1- nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546 (setq first nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 ((looking-at "is")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 ;; check if it is only a type definition
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 (skip-chars-backward "a-zA-Z0-9_.'")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2553 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2554 (backward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2555 (looking-at ")"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2556 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2558 (backward-sexp 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2559 (skip-chars-backward "a-zA-Z0-9_.'")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2560 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 (looking-at "\\<type\\>")) ; end of save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2563 (goto-char (match-beginning 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 (setq nest-count (1- nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 (setq first nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2568 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2569 ((looking-at "new")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2570 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2571 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2572 (looking-at "is"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2573 (goto-char (match-beginning 0))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 ((and first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2576 (looking-at "begin"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2577 (setq nest-count 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 (setq flag t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582 (setq first nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 ) ;; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 ;; check if declaration-start is really found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (if (not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589 (zerop nest-count)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2590 (not flag)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2592 (if (looking-at "is")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 "\\<\\(procedure\\|function\\|task\\|package\\)\\>" t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 (looking-at "declare\\|generic")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596 (if noerror nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2597 (error "no matching procedure/function/task/declare/package"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2599
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2600
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2601 (defun ada-goto-matching-start (&optional nest-level noerror gotothen)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2602 ;; Moves point to the beginning of a block-start. Which block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2603 ;; depends on the value of NEST-LEVEL, which defaults to zero. If
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2604 ;; NOERROR is non-nil, it only returns nil if no matching start was
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2605 ;; found. If GOTOTHEN is non-nil, point moves to the 'then'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2606 ;; following 'if'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 (found nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 (pos nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2617 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 "end\\|loop\\|select\\|begin\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2619 "if\\|task\\|package\\|record\\|do\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2620 t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2621
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2622 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2625 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2626 ;; found block end => increase nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2627 ((looking-at "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2628 (setq nest-count (1+ nest-count)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2629 ;; found loop/select/record/case/if => check if it starts or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630 ;; ends a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2631 ((looking-at "loop\\|select\\|record\\|case\\|if")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 (setq pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2635 ;; check if keyword follows 'end'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2636 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 (if (looking-at "\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2639 ;; it ends a block => increase nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2642 (setq pos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 ;; it starts a block => decrease nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2644 (setq nest-count (1- nest-count))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2645 (goto-char pos))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 ;; found package start => check if it really is a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 ((looking-at "package")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2648 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2649 (ada-search-ignore-string-comment "\\<is\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 ;; ignore it if it is only a declaration with 'new'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2652 (if (not (looking-at "\\<new\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653 (setq nest-count (1- nest-count)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 ;; found task start => check if it has a body
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2655 ((looking-at "task")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2656 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2658 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2659 ;; ignore it if it has no body
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 (if (not (looking-at "\\<body\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2661 (setq nest-count (1- nest-count)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2662 ;; all the other block starts
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2664 (setq nest-count (1- nest-count)))) ; end of 'cond'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2665
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2666 ;; match is found, if nest-depth is zero
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2667 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2668 (setq found (zerop nest-count))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2669
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2670 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2671 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2672 ;; match found => is there anything else to do ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2673 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2674 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2675 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2676 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2677 ;; found 'if' => skip to 'then', if it's on a separate line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678 ;; and GOTOTHEN is non-nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2679 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2680 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2681 gotothen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2682 (looking-at "if")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2683 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2684 (ada-search-ignore-string-comment "\\<then\\>" nil nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2685 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2686 (looking-at "\\<then\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2687 (goto-char (match-beginning 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2688 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2689 ;; found 'do' => skip back to 'accept'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2690 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2691 ((looking-at "do")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 (if (not (ada-search-ignore-string-comment "\\<accept\\>" t nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2693 (error "missing 'accept' in front of 'do'"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2694 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2696 (if noerror
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2697 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2698 (error "no matching start")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2699
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2701 (defun ada-goto-matching-end (&optional nest-level noerror)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2702 ;; Moves point to the end of a block. Which block depends on the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2703 ;; value of NEST-LEVEL, which defaults to zero. If NOERROR is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 ;; non-nil, it only returns nil if found no matching start.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2705 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2706 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2707
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2708 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2709 ;; search forward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2710 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2711 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2712 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2713 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2714 (concat "\\<\\(end\\|loop\\|select\\|begin\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2715 "if\\|task\\|package\\|record\\|do\\)\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2716
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2717 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2718 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2719 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2720 (backward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2721 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2722 ;; found block end => decrease nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2723 ((looking-at "\\<end\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2724 (setq nest-count (1- nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2725 ;; skip the following keyword
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2726 (if (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2727 (skip-chars-forward "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2728 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2729 (looking-at "\\<\\(loop\\|select\\|record\\|case\\|if\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2730 (forward-word 1)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2731 ;; found package start => check if it really starts a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2732 ((looking-at "\\<package\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2733 (ada-search-ignore-string-comment "\\<is\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2734 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2735 ;; ignore and skip it if it is only a 'new' package
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2736 (if (not (looking-at "\\<new\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2737 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2738 (skip-chars-forward "new")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2739 ;; all the other block starts
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2740 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2741 (setq nest-count (1+ nest-count))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2742 (forward-word 1))) ; end of 'cond'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2743
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2744 ;; match is found, if nest-depth is zero
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2745 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2746 (setq found (zerop nest-count))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2747
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2748 (if (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2749 (if noerror
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2750 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2751 (error "no matching end"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2752 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2753
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2755 (defun ada-forward-sexp-ignore-comment ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2756 ;; Skips one sexp forward, ignoring comments.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2757 (while (looking-at "[ \t\n]*--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2758 (skip-chars-forward "[ \t\n]")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2759 (end-of-line))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2760 (forward-sexp 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2761
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2762
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2763 (defun ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2764 (search-re &optional backward limit paramlists)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2765 ;; Regexp-Search for SEARCH-RE, ignoring comments, strings and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 ;; parameter lists, if PARAMLISTS is nil. Returns a cons cell of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767 ;; begin and end of match data or nil, if not found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2768 (let ((found nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2769 (begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2770 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2771 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2772 (search-func
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2773 (if backward 're-search-backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2774 're-search-forward)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2775
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2776 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2777 ;; search until found or end-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2778 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779 (while (and (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 (funcall search-func search-re limit 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2781 (setq begin (match-beginning 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2782 (setq end (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2784 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2785 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2786 ;; found in comment => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2787 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2788 ((ada-in-comment-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2789 (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2790 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791 (re-search-backward "--" nil 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792 (goto-char (match-beginning 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2794 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2795 (beginning-of-line))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2796 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2797 ;; found in string => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2798 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2799 ((ada-in-string-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2800 (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2801 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2802 (re-search-backward "\"\\|#" nil 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2803 (goto-char (match-beginning 0))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2804 (re-search-forward "\"\\|#" nil 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2805 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2806 ;; found character constant => ignore it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2807 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2808 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2809 (setq pos (- (point) (if backward 1 2)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2810 (and (char-after pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2811 (= (char-after pos) ?')
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2812 (= (char-after (+ pos 2)) ?')))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2813 ())
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2814 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2815 ;; found a parameter-list but should ignore it => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2816 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2817 ((and (not paramlists)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2818 (ada-in-paramlist-p))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2819 (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2820 (ada-search-ignore-string-comment "(" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2821 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2822 ;; directly in front of a comment => skip it, if searching forward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2823 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2824 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2825 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2826 (looking-at "--"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2827 (if (not backward)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2828 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2829 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2830 (beginning-of-line))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2831 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2832 ;; found what we were looking for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2833 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2834 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2835 (setq found t)))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2837 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838 (cons begin end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2840
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2841
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842 (defun ada-search-but-not (search-re not-search-re &optional backward limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843 ;; Searches SEARCH-RE, ignoring parts of NOT-SEARCH-RE, strings,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 ;; comments and parameter-lists.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 (begin-not nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2848 (begin-end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2849 (end-not nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2850 (ret-cons nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2851 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2852
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2853 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2854 ;; search until found or end-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 (setq ret-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2860 (ada-search-ignore-string-comment search-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2861 backward limit))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 (if (consp ret-cons)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864 (setq begin (car ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865 (setq end (cdr ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 (if (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2870 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2871 ;; if no NO-SEARCH-RE was found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2872 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2873 (not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2874 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2875 (setq ret-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2876 (ada-search-ignore-string-comment not-search-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2877 backward nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2878 (if (consp ret-cons)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2879 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880 (setq begin-not (car ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 (setq end-not (cdr ret-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885 ;; or this NO-SEARCH-RE is not a part of the SEARCH-RE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 ;; found before.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889 (<= end-not begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890 (>= begin-not end)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892 (setq found t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2894 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2895 ;; not found the correct match => skip this match
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2896 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2897 (goto-char (if backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2898 begin
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2899 end)))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2900
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2901 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903 (goto-char begin)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2904 (cons begin end))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2907
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2908 (defun ada-goto-prev-nonblank-line ( &optional ignore-comment)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2909 ;; Moves point to previous non-blank line,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2910 ;; ignoring comments if IGNORE-COMMENT is non-nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2911 ;; It returns t if a matching line was found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2912 (let ((notfound t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2913 (newpoint nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2914
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2915 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2916 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2917 ;; backward one line, if there is one
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2918 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2919 (if (zerop (forward-line -1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921 ;; there is some kind of previous line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2922 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2923 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2924 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 (setq newpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2927 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2928 ;; search until found or beginning-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930 (while (and (setq notfound
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931 (or (looking-at "[ \t]*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932 (and (looking-at "[ \t]*--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2933 ignore-comment)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 (not (in-limit-line-p)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2935 (forward-line -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 (setq newpoint (point))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2938
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2939 )) ; end of if
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2940
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2941 ) ; end of save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2942
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2943 (if notfound nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2944 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2945 (goto-char newpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949 (defun ada-goto-next-nonblank-line ( &optional ignore-comment)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 ;; Moves point to next non-blank line,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 ;; ignoring comments if IGNORE-COMMENT is non-nil.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2952 ;; It returns t if a matching line was found.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953 (let ((notfound t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 (newpoint nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2956 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2957 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2958 ;; forward one line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 (if (zerop (forward-line 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962 ;; there is some kind of previous line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2964 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2965 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2966 (setq newpoint (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2967
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2968 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 ;; search until found or end-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2970 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2971 (while (and (setq notfound
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972 (or (looking-at "[ \t]*$")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (and (looking-at "[ \t]*--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974 ignore-comment)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2975 (not (in-limit-line-p)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 (setq newpoint (point))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2980 )) ; end of if
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2982 ) ; end of save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2983
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2984 (if notfound nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2985 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2986 (goto-char newpoint)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2987 t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2988
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2989
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2990 ;; ---- boolean functions for indentation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2991
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2992 (defun ada-in-decl-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2993 ;; Returns t if point is inside a declarative part.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2994 ;; Assumes point to be at the end of a statement.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2995 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2996 (ada-in-paramlist-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2997 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2998 (ada-goto-matching-decl-start t))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2999
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3000
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3001 (defun ada-looking-at-semi-or ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3002 ;; Returns t if looking-at an 'or' following a semicolon.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3003 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3004 (and (looking-at "\\<or\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3005 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3006 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3007 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3008 (looking-at "\\<or\\>")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3009
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3010
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3011 (defun ada-looking-at-semi-private ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3012 ;; Returns t if looking-at an 'private' following a semicolon.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3013 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3014 (and (looking-at "\\<private\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3015 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3017 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3018 (looking-at "\\<private\\>")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3019
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3020
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3021 (defun in-limit-line-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022 ;; Returns t if point is in first or last accessible line.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3023 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3024 (>= 1 (count-lines (point-min) (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3025 (>= 1 (count-lines (point) (point-max)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3027
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3028 (defun ada-in-comment-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3029 ;; Returns t if inside a comment.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3030 (save-excursion (and (re-search-backward "\\(--\\|\n\\)" nil 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3031 (looking-at "-"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3032
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3033
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3034 (defun ada-in-string-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3035 ;; Returns t if point is inside a string
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3036 ;; (Taken from pascal-mode.el, modified by MH).
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3037 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3038 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3039 (nth 3 (parse-partial-sexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3040 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3041 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3042 (point)) (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3043 ;; check if 'string quote' is only a character constant
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3044 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3045 (re-search-backward "\"\\|#" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3046 (not (= (char-after (1- (point))) ?'))))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3047
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3048
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3049 (defun ada-in-string-or-comment-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3050 ;; Returns t if point is inside a string or a comment.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3051 (or (ada-in-comment-p)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3052 (ada-in-string-p)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3053
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3054
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3055 (defun ada-in-paramlist-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056 ;; Returns t if point is inside a parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 ;; following 'function'/'procedure'/'package'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 (re-search-backward "(\\|)" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061 ;; inside parentheses ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3062 (looking-at "(")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3063 (backward-word 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3064 ;; right keyword before paranthesis ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3065 (looking-at (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3066 "procedure\\|function\\|body\\|package\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3067 "task\\|entry\\|accept\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3068 (re-search-forward ")\\|:" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3069 ;; at least one ':' inside the parentheses ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3070 (not (backward-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3071 (looking-at ":"))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3072
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3073
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3074 ;; not really a boolean function ...
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3075 (defun ada-in-open-paren-p ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3076 ;; If point is somewhere behind an open parenthesis not yet closed,
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3077 ;; it returns the column # of the first non-ws behind this open
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3078 ;; parenthesis, otherwise nil."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3079 (let ((nest-count 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3080 (limit nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3081 (found nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3082 (pos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3083 (col nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3084 (counter ada-search-paren-line-count-limit))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3085
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3086 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3087 ;; get search-limit
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3088 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3089 (if ada-search-paren-line-count-limit
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3090 (setq limit
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3091 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3092 (while (not (zerop counter))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3093 (ada-goto-prev-nonblank-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3094 (setq counter (1- counter)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3095 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3098 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3099
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3100 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3101 ;; loop until found or limit
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3102 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3103 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3104 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3105 (ada-search-ignore-string-comment "(\\|)" t limit t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3106 (setq nest-count
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3107 (if (looking-at ")")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 (1+ nest-count)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 (1- nest-count)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3110 (setq found (zerop nest-count))) ; end of loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3111
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3112 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3113 ;; if found => return column of first non-ws after the parenthesis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3114 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3115 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3116 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 (re-search-forward "[^ \t]" nil 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3118 (backward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3119 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3120 (not (looking-at "\n"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3121 (setq col (current-column))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3122 col
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3123 (current-column)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3124 nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3126
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3127 ;;;-----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3128 ;;; Simple Completion Functions ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3129 ;;;-----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3130
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3131 ;; These are my first steps in Emacs-Lisp ... :-) They can be replaced
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3132 ;; by functions based on the output of the Gnatf Tool that comes with
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3133 ;; the GNAT Ada compiler. See the file ada-xref.el (MH) But you might
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3134 ;; use these functions if you don't use GNAT
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3135
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3136 (defun ada-use-last-with ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3137 "Inserts the package name of the last 'with' statement after use."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3138 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3139 (let ((pakname nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3140 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3141 (forward-word -1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3142 (if (looking-at "use")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3143 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3144 ;; find last 'with'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3145 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3146 (progn (re-search-backward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3147 "\\(\\<with\\s-+\\)\\([a-zA-Z0-9_.]+\\)\\(\\s-*;\\)")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3148 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3149 ;; get the name of the package
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3150 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 (setq pakname (concat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3152 (buffer-substring (match-beginning 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3153 (match-end 2))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3154 ";")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3155 (setq pakname "")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3156 (insert pakname)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3157
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3158
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3159 (defun ada-complete-symbol (symboldef position symalist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3160 ;; Tries to complete a symbol in the buffer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3161 ;; SYMBOLDEF is the regexp to find the definition of the desired symbol.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3162 ;; POSITION is the position of the subexpression in SYMBOLDEF to match
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3163 ;; the symbol itself.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3164 ;; SYMALIST is an alist with possibly predefined completions."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3165 (let ((sofar nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3166 (completed nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3167 (insertpos nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3168 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3170 ;; get the part of the symbol already typed
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3171 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3172 (re-search-backward "\\([^a-zA-Z0-9_\\.]\\)\\([a-zA-Z0-9_\\.]+\\)")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 (setq sofar (buffer-substring (match-beginning 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3174 (match-end 2)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3175 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3176 ;; delete it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3177 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3178 (delete-region (setq insertpos (match-beginning 2))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3179 (match-end 2))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3180 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3181 ;; find all possible completions by searching for definitions of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3182 ;; this kind of symbol
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3183 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3184 (while (re-search-backward symboldef nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3185 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3186 ;; build an alist of these possible completions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3187 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3188 (setq symalist (cons (cons (buffer-substring (match-beginning position)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3189 (match-end position))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3190 nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3191 symalist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3192
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3193 (or
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3194 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 ;; symbol gets completed as far as possible
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (stringp (setq completed (try-completion sofar symalist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199 ;; or is already complete
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201 (setq completed sofar)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 ;; insert the completed symbol
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (goto-char insertpos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 (insert completed)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3207
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3209 (defun ada-complete-use ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3210 "Tries to complete the package name in an 'use' statement in the buffer.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3211 Searches through former 'with' statements for possible completions."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3212 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3213 (ada-complete-symbol
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3214 "\\(\\<with\\s-+\\)\\([a-zA-Z0-9_.]+\\)\\(\\s-*;\\)" 2 nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3215 (insert ";"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3216
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3217
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3218 (defun ada-complete-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3219 "Tries to complete a procedure/function name in the buffer."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3220 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221 (ada-complete-symbol ada-procedure-start-regexp 2 nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3223
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 (defun ada-complete-variable ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3225 "Tries to complete a variable name in the buffer."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3226 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3227 (ada-complete-symbol
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3228 "\\([^a-zA-Z0-9_]\\)\\([a-zA-Z0-9_]+\\)[ \t\n]+\\(:\\)" 2 nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3229
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3230
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3231 (defun ada-complete-type ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3232 "Tries to complete a type name in the buffer."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3233 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234 (ada-complete-symbol "\\(type\\)[ \t\n]+\\([a-zA-Z0-9_\\.]+\\)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 2
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236 '(("Integer" nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 ("Long_Integer" nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 ("Natural" nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 ("Positive" nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 ("Short_Integer" nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3241
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3243 ;;;----------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3244 ;;; Behaviour Of TAB Key ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3245 ;;;----------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 (defun ada-tab ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3248 "Do indenting or tabbing according to `ada-tab-policy'."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (cond ((eq ada-tab-policy 'indent-and-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3251 ;; ada-indent-and-tab
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3252 ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3253 ((eq ada-tab-policy 'indent-auto) (ada-indent-current))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3254 ((eq ada-tab-policy 'gei) (ada-tab-gei))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3255 ((eq ada-tab-policy 'indent-af) (af-indent-line)) ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3256 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3258
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3260 (defun ada-untab (arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3261 "Delete leading indenting according to `ada-tab-policy'."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3262 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3263 (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3264 ((eq ada-tab-policy 'indent-af) (backward-delete-char-untabify ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3265 (prefix-numeric-value arg) ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266 arg)) ; GEB
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3267 ((eq ada-tab-policy 'indent-auto) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3268 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3271
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3272 (defun ada-indent-current-function ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3273 "ada-mode version of the indent-line-function."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3274 (interactive "*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3275 (let ((starting-point (point-marker)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 (ada-beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3277 (ada-tab)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3278 (if (< (point) starting-point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3279 (goto-char starting-point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3280 (set-marker starting-point nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3281 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3283
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3284
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3285
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3286 (defun ada-tab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3287 "Indent current line to next tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3288 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3289 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3290 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3291 (insert-char ? ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3292 (if (save-excursion (= (point) (progn (beginning-of-line) (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3293 (forward-char ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3294
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3295
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3296 (defun ada-untab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3297 "indent current line to previous tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3298 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3299 (let ((bol (save-excursion (progn (beginning-of-line) (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3300 (eol (save-excursion (progn (end-of-line) (point)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3301 (indent-rigidly bol eol (- 0 ada-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3302
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3304 (defun ada-tabsize (s)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 "changes spacing used for indentation. Reads spacing from minibuffer."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 (interactive "nnew indentation spacing: ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307 (setq ada-indent s))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3308
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3309
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3310 ;;;---------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 ;;; Miscellaneous ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 ;;;---------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3313
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3314 (defun ada-remove-trailing-spaces ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 ;; remove all trailing spaces at the end of lines.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3316 "remove trailing spaces in the whole buffer."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3317 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3318 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3319 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3320 (while (re-search-forward "[ \t]+$" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3321 (replace-match "" nil nil))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3322
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3323
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3324 (defun ada-untabify-buffer ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3325 ;; change all tabs to spaces
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3326 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3327 (untabify (point-min) (point-max))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3328
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3329
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3330 (defun ada-uncomment-region (beg end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3331 "delete comment-start at the beginning of a line in the region."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332 (interactive "r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3333 (comment-region beg end -1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3334
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3335
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3336 ;; define a function to support find-file.el if loaded
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3337 (defun ada-ff-other-window ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3338 "Find other file in other window using ff-find-other-file."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3339 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3340 (and (fboundp 'ff-find-other-file)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3341 (ff-find-other-file t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3342
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3343
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3344 ;;;-------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3345 ;;; Moving To Procedures/Packages ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3346 ;;;-------------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3347
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3348 (defun ada-next-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 "Moves point to next procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3352 (if (re-search-forward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3354 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3355
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 (defun ada-previous-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 "Moves point to previous procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3358 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3360 (if (re-search-backward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3361 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3362 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3363
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3364 (defun ada-next-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 "Moves point to next package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3368 (if (re-search-forward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3369 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3370 (error "No more packages")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3371
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 (defun ada-previous-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 "Moves point to previous package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3374 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3375 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3376 (if (re-search-backward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3377 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3378 (error "No more packages")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3380
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3381 ;;;-----------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3382 ;;; define keymap for Ada
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3383 ;;;-----------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3384
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3385 (if (not ada-mode-map)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3386 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3387 (setq ada-mode-map (make-sparse-keymap))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3388
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3389 ;; Indentation and Formatting
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3390 (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3391 (define-key ada-mode-map "\t" 'ada-tab)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3392 (define-key ada-mode-map "\C-c\C-l" 'ada-indent-region)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3393 ;; How do I write this for working with Lucid Emacs?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3394 (define-key ada-mode-map [S-tab] 'ada-untab)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3395 (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3396 (define-key ada-mode-map "\C-c\C-p" 'ada-call-pretty-printer)
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3397 ;;; We don't want to make meta-characters case-specific.
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3398 ;;; (define-key ada-mode-map "\M-Q" 'ada-fill-comment-paragraph-justify)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3399 (define-key ada-mode-map "\M-\C-q" 'ada-fill-comment-paragraph-postfix)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3400
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3401 ;; Movement
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3402 ;;; It isn't good to redefine these. What should be done instead? -- rms.
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3403 ;;; (define-key ada-mode-map "\M-e" 'ada-next-procedure)
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3404 ;;; (define-key ada-mode-map "\M-a" 'ada-previous-procedure)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3405 (define-key ada-mode-map "\M-\C-e" 'ada-next-package)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406 (define-key ada-mode-map "\M-\C-a" 'ada-previous-package)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3407 (define-key ada-mode-map "\C-c\C-a" 'ada-move-to-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3408 (define-key ada-mode-map "\C-c\C-e" 'ada-move-to-end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3409
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3410 ;; Compilation
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3411 (define-key ada-mode-map "\C-c\C-c" 'compile)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3412
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3413 ;; Casing
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3414 (define-key ada-mode-map "\C-c\C-r" 'ada-adjust-case-region)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3415 (define-key ada-mode-map "\C-c\C-b" 'ada-adjust-case-buffer)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3416
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3417 (define-key ada-mode-map "\177" 'backward-delete-char-untabify)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3418
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3419 ;; Use predefined function of emacs19 for comments (RE)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3420 (define-key ada-mode-map "\C-c;" 'comment-region)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3421 (define-key ada-mode-map "\C-c:" 'ada-uncomment-region)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3422
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3423 ;; Change basic functionality
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3424 (mapcar (lambda (pair)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3425 (substitute-key-definition (car pair) (cdr pair)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3426 ada-mode-map global-map))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3427 '((beginning-of-line . ada-beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3428 (end-of-line . ada-end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429 (forward-to-indentation . ada-forward-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3431 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434 ;;;-------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435 ;;; define menu 'Ada'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436 ;;;-------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3437
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3438 (defun ada-add-ada-menu ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3439 "Adds the menu 'Ada' to the menu-bar in Ada Mode."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3440 (easy-menu-define t ada-mode-map t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3441 '("Ada"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3442 ["next package" ada-next-package t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3443 ["previous package" ada-previous-package t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3444 ["next procedure" ada-next-procedure t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3445 ["previous procedure" ada-previous-procedure t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3446 ["goto start" ada-move-to-start t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3447 ["goto end" ada-move-to-end t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3448 ["------------------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3449 ["indent current line (TAB)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3450 ada-indent-current-function t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3451 ["indent lines in region" ada-indent-region t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3452 ["format parameter list" ada-format-paramlist t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3453 ["pretty print buffer" ada-call-pretty-printer t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3454 ["------------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3455 ["fill comment paragraph"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3456 ada-fill-comment-paragraph t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3457 ["justify comment paragraph"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3458 ada-fill-comment-paragraph-justify t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3459 ["postfix comment paragraph"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3460 ada-fill-comment-paragraph-postfix t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3461 ["------------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3462 ["adjust case region" ada-adjust-case-region t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3463 ["adjust case buffer" ada-adjust-case-buffer t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3464 ["----------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3465 ["comment region" comment-region t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3466 ["uncomment region" ada-uncomment-region t]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3467 ["----------------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3468 ["compile" compile (fboundp 'compile)]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469 ["next error" next-error (fboundp 'next-error)]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3470 ["---------------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3471 ["Index" imenu (fboundp 'imenu)]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472 ["--------------" nil nil]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3473 ["other file other window" ada-ff-other-window
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3474 (fboundp 'ff-find-other-file)]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3475 ["other file" ff-find-other-file
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3476 (fboundp 'ff-find-other-file)])))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3477
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3478
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3479 ;;;-------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3480 ;;; Define Some Support Functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3481 ;;;-------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3482
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3483 (defun ada-beginning-of-line (&optional arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3484 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3485 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3486 ((eq ada-tab-policy 'indent-af) (af-beginning-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3487 (t (beginning-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3488 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3489
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 (defun ada-end-of-line (&optional arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3491 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 ((eq ada-tab-policy 'indent-af) (af-end-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494 (t (end-of-line arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3496
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497 (defun ada-current-column ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3499 ((eq ada-tab-policy 'indent-af) (af-current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3500 (t (current-column))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3501 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3502
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3503 (defun ada-forward-to-indentation (&optional arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506 ((eq ada-tab-policy 'indent-af) (af-forward-to-indentation arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507 (t (forward-to-indentation arg))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3509
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3510 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3511 ;;; support for find-file
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3512 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3513
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3514 (defvar ada-krunch-args "8"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3515 "*Argument of gnatk8, a string containing the max number of characters.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3516 Set to a big number, if you dont use crunched filenames.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3517
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3518 (defun ada-make-filename-from-adaname (adaname)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3519 "determine the filename of a package/procedure from its own Ada name."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520 ;; this is done simply by calling gkrunch, when we work with GNAT. It
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3521 ;; must be a more complex function in other compiler environments.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3522 (interactive "s")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3523
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3524 ;; things that should really be done by the external process
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3525 (let (krunch-buf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3526 (setq krunch-buf (generate-new-buffer "*gkrunch*"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3527 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 (set-buffer krunch-buf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529 (insert (downcase adaname))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3530 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3531 (while (search-forward "." nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532 (replace-match "-" nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 (setq adaname (buffer-substring (point-min)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538 ;; clean the buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 (delete-region (point-min) (point-max))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3540 ;; send adaname to external process "gnatk8"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3541 (call-process "gnatk8" nil krunch-buf nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3542 adaname ada-krunch-args)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 ;; fetch output of that process
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544 (setq adaname (buffer-substring
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3545 (point-min)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3546 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3548 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3549 (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3550 (kill-buffer krunch-buf)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551 (setq adaname adaname) ;; can I avoid this statement?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3553
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3554 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3555 ;;; support for imenu
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3556 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3557
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3558 (defun imenu-create-ada-index (&optional regexp)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3559 "create index alist for Ada files."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3560 (let ((index-alist '())
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3561 prev-pos char)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3563 ;(imenu-progress-message prev-pos 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564 ;; Search for functions/procedures
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3565 (save-match-data
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3566 (while (re-search-forward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3567 (or regexp ada-procedure-start-regexp)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568 nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3569 ;(imenu-progress-message prev-pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3570 ;;(backward-up-list 1) ;; needed in Ada ????
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3571 ;; do not store forward definitions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3572 (save-match-data
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3573 (if (not (looking-at (concat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574 "[ \t\n]*" ; WS
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575 "\([^)]+\)" ; parameterlist
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3576 "\\([ \n\t]+return[ \n\t]+"; potential return
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3577 "[a-zA-Z0-9_\\.]+\\)?"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3578 "[ \t]*" ; WS
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3579 ";" ;; THIS is what we really look for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3580 )))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3581 ; (push (imenu-example--name-and-position) index-alist)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3582 (setq index-alist (cons (imenu-example--name-and-position)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3583 index-alist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3584 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3585 ;(imenu-progress-message 100)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3586 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3587 (nreverse index-alist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3588
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3589 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3590 ;;; support for font-lock
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3591 ;;;---------------------------------------------------
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3593 ;; Strings are a real pain in Ada because both ' and " can appear in a
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3594 ;; non-string quote context (the former as an operator, the latter as
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3595 ;; a character string). We follow the least losing solution, in which
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3596 ;; only " is a string quote. Therefore a character string of the form
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 ;; '"' will throw fontification off on the wrong track.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3598
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599 (defconst ada-font-lock-keywords-1
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 ;; Function, package (body), pragma, procedure, task (body) plus name.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3603 (list (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604 "function\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 "p\\(ackage\\(\\|[ \t]+body\\)\\|r\\(agma\\|ocedure\\)\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606 "task\\(\\|[ \t]+body\\)"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3607 "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608 '(1 font-lock-keyword-face) '(6 font-lock-function-name-face nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3609 "For consideration as a value of `ada-font-lock-keywords'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3610 This does fairly subdued highlighting.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3611
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3612 (defconst ada-font-lock-keywords-2
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3613 (append ada-font-lock-keywords-1
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3614 (list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3616 ;; Main keywords, except those treated specially below.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617 (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618 ; ("abort" "abs" "abstract" "accept" "access" "aliased" "all"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619 ; "and" "array" "at" "begin" "case" "declare" "delay" "delta"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 ; "digits" "do" "else" "elsif" "entry" "exception" "exit" "for"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621 ; "generic" "if" "in" "is" "limited" "loop" "mod" "not"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622 ; "null" "or" "others" "private" "protected"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623 ; "range" "record" "rem" "renames" "requeue" "return" "reverse"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 ; "select" "separate" "tagged" "task" "terminate" "then" "until"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 ; "while" "xor")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 "a\\(b\\(ort\\|s\\(\\|tract\\)\\)\\|cce\\(pt\\|ss\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627 "l\\(iased\\|l\\)\\|nd\\|rray\\|t\\)\\|begin\\|case\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628 "d\\(e\\(clare\\|l\\(ay\\|ta\\)\\)\\|igits\\|o\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3629 "e\\(ls\\(e\\|if\\)\\|ntry\\|x\\(ception\\|it\\)\\)\\|for\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3630 "generic\\|i[fns]\\|l\\(imited\\|oop\\)\\|mod\\|n\\(ot\\|ull\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 "o\\(r\\|thers\\|ut\\)\\|pr\\(ivate\\|otected\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 "r\\(ange\\|e\\(cord\\|m\\|names\\|queue\\|turn\\|verse\\)\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633 "se\\(lect\\|parate\\)\\|"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634 "t\\(a\\(gged\\|sk\\)\\|erminate\\|hen\\)\\|until\\|while\\|xor"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635 "\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3637 ;; Anything following end and not already fontified is a body name.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3638 '("\\<\\(end\\)\\>[ \t]*\\(\\sw+\\)?"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641 ;; Variable name plus optional keywords followed by a type name. Slow.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3642 ; (list (concat "\\<\\(\\sw+\\)\\>[ \t]*:?[ \t]*"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3643 ; "\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)?[ \t]*"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 ; "\\(\\sw+\\)?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3645 ; '(1 font-lock-variable-name-face)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3646 ; '(2 font-lock-keyword-face nil t) '(3 font-lock-type-face nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3648 ;; Optional keywords followed by a type name.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3649 (list (concat ; ":[ \t]*"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3650 "\\<\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 "[ \t]*"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652 "\\(\\sw+\\)?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3655 ;; Keywords followed by a type or function name.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3656 (list (concat "\\<\\("
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 "new\\|of\\|subtype\\|type"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3658 "\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*\\((\\)?")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659 '(1 font-lock-keyword-face)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660 '(2 (if (match-beginning 4)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 font-lock-function-name-face
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3662 font-lock-type-face) nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3663 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3664 ;; Keywords followed by a (comma separated list of) reference.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3665 (list (concat "\\<\\(goto\\|raise\\|use\\|when\\|with\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3666 ; "[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?") ; RE
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667 "[ \t]*\\([a-zA-Z0-9_\\.\\|, ]+\\)\\W")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3668 '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3670 ;; Goto tags.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3671 '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3672 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 "For consideration as a value of `ada-font-lock-keywords'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3674 This does a lot more highlighting.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675
10880
7c5fe757600b Use font-lock-maximum-decoration when setting ada-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents: 10707
diff changeset
3676 (defvar ada-font-lock-keywords (if font-lock-maximum-decoration
7c5fe757600b Use font-lock-maximum-decoration when setting ada-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents: 10707
diff changeset
3677 ada-font-lock-keywords-2
7c5fe757600b Use font-lock-maximum-decoration when setting ada-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents: 10707
diff changeset
3678 ada-font-lock-keywords-1)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 "*Expressions to highlight in Ada mode.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3681 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3682 ;;; ????
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 (defun ada-gen-comment-until-proc ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3685 ;; comment until spec of a procedure or a function.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3686 (forward-line 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3687 (set-mark-command (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688 (if (re-search-forward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3689 (progn (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3690 (comment-region (mark) (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3691 (error "No more functions/procedures")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3692
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3693
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3694 (defun ada-gen-treat-proc nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3695 ;; make dummy body of a procedure/function specification.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3696 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3697 (let ((wend (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3698 (wstart (progn (re-search-backward "[ ][a-zA-Z0-9_\"]+" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3699 (+ (match-beginning 0) 1)))) ; delete leading WS
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3700 (copy-region-as-kill wstart wend) ; store proc name in kill-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3701
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3702
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3703 ;; if the next notWS char is '(' ==> parameterlist follows
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3704 ;; if the next notWS char is ';' ==> no paramterlist
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3705 ;; if the next notWS char is 'r' ==> paramterless function, search ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3706
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 ;; goto end of regex before last (= end of procname)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3708 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709 ;; look for next non WS
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710 (backward-char)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 (re-search-forward "[ ]*.")
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3712 (if (char-equal (char-after (match-end 0)) ?\;)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3713 (delete-char 1) ;; delete the ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3714 ;; else
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715 ;; find ');' or 'return <id> ;'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3716 (re-search-forward
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3717 "\\()[ \t]*;\\)\\|\\(return[ \t]+[a-zA-Z0-9_]+[ \t]*;\\)" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3718 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3719 (delete-backward-char 1) ;; delete the ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3720 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3721
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3722 (insert " is")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3723 ;; if it is a function, we should generate a return variable and a
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3724 ;; return statement. Sth. like "Result : <return-type>;" and a
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3725 ;; "return Result;".
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3726 (ada-indent-newline-indent)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3727 (insert "begin -- ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3728 (yank)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3729 (newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3730 (insert "null;")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3731 (newline)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3732 (insert "end ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3733 (yank)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3734 (insert ";")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3735 (ada-indent-newline-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3736
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3737
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3738 (defun ada-gen-make-bodyfile (spec-filename)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3739 "Create a new buffer containing the correspondig Ada body
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3740 to the current specs."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3741 (interactive "b")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3742 ;;; (let* (
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3743 ;;; (file-name (ada-body-filename spec-filename))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3744 ;;; (buf (get-buffer-create file-name)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3745 ;;; (switch-to-buffer buf)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3746 ;;; (ada-mode)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3747 (ff-find-other-file t t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3748 ;;; (if (= (buffer-size) 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3749 ;;; (make-header)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3750 ;;; ;; make nothing, autoinsert.el had put something in already
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3751 ;;; )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3752 (end-of-buffer)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3753 (let ((hlen (count-lines (point-min) (point-max))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3754 (insert-buffer spec-filename)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3755 ;; hlen lines have already been inserted automatically
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3756 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3758 (if (re-search-forward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3759 (progn (goto-char (match-end 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3760 (insert " body"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3761 (error "No package"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 ; (comment-until-proc)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3763 ; does not work correctly
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 ; must be done by hand
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3765
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3766 (while (re-search-forward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3767 (ada-gen-treat-proc))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3768
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3769 ; don't overwrite an eventually
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3770 ; existing file
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771 ; (if (file-exists-p file-name)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772 ; (error "File with this name already exists!")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3773 ; (write-file file-name))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3774 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3775
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3776 ;;; provide ourself
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3777
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3778 (provide 'ada-mode)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3779
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
3780 ;;; ada-mode.el ends here