annotate lisp/progmodes/ada-mode.el @ 31780:d2b5643aab16

(gnus-smiley-display): Autoload from smiley-ems. (mouse-set-point, set-face-foreground) (set-face-background, x-popup-menu) [not window-system]: Don't zap them.
author Dave Love <fx@gnu.org>
date Wed, 20 Sep 2000 16:42:43 +0000
parents 41f228350eca
children 5acb191f2a15
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1 ;; @(#) ada-mode.el --- major-mode for editing Ada source.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3 ;; Copyright (C) 1994, 1995, 1997-1999, 2000 Free Software Foundation, Inc.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
5 ;; Author: Rolf Ebert <ebert@inf.enst.fr>
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
6 ;; Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
7 ;; Emmanuel Briot <briot@gnat.com>
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
8 ;; Maintainer: Emmanuel Briot <briot@gnat.com>
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
9 ;; Ada Core Technologies's version: $Revision: 1.117 $
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
10 ;; Keywords: languages ada
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
11
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
12 ;; This file is not part of GNU Emacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
13
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
14 ;; This program is free software; you can redistribute it and/or modify
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; 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
16 ;; the Free Software Foundation; either version 2, or (at your option)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; any later version.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
19 ;; This program is distributed in the hope that it will be useful,
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; GNU General Public License for more details.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
26 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
27
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
28 ;;; Commentary:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
29 ;;; This mode is a major mode for editing Ada83 and Ada95 source code.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
30 ;;; This is a major rewrite of the file packaged with Emacs-20. The
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
31 ;;; ada-mode is composed of four lisp file, ada-mode.el, ada-xref.el,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
32 ;;; ada-prj.el and ada-stmt.el. Only this file (ada-mode.el) is
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
33 ;;; completely independent from the GNU Ada compiler Gnat, distributed
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
34 ;;; by Ada Core Technologies. All the other files rely heavily on
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
35 ;;; features provides only by Gnat.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
37 ;;; Note: this mode will not work with Emacs 19. If you are on a VMS
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
38 ;;; system, where the latest version of Emacs is 19.28, you will need
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
39 ;;; another file, called ada-vms.el, that provides some required
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
40 ;;; functions.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
41
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
42 ;;; Usage:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
43 ;;; Emacs should enter Ada mode automatically when you load an Ada file.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
44 ;;; By default, the valid extensions for Ada files are .ads, .adb or .ada
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
45 ;;; If the ada-mode does not start automatically, then simply type the
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
46 ;;; following command :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
47 ;;; M-x ada-mode
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
48 ;;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
49 ;;; By default, ada-mode is configured to take full advantage of the GNAT
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
50 ;;; compiler (the menus will include the cross-referencing features,...).
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
51 ;;; If you are using another compiler, you might want to set the following
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
52 ;;; variable in your .emacs (Note: do not set this in the ada-mode-hook, it
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
53 ;;; won't work) :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
54 ;;; (setq ada-which-compiler 'generic)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
55 ;;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
56 ;;; This mode requires find-file.el to be present on your system.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
57
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
58 ;;; History:
11199
394f205af26d Fix comments.
Karl Heuer <kwzh@gnu.org>
parents: 10880
diff changeset
59 ;;; The first Ada mode for GNU Emacs was written by V. Broman in
394f205af26d Fix comments.
Karl Heuer <kwzh@gnu.org>
parents: 10880
diff changeset
60 ;;; 1985. He based his work on the already existing Modula-2 mode.
394f205af26d Fix comments.
Karl Heuer <kwzh@gnu.org>
parents: 10880
diff changeset
61 ;;; This was distributed as ada.el in versions of Emacs prior to 19.29.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;;; Lynn Slater wrote an extensive Ada mode in 1989. It consisted of
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;;; several files with support for dired commands and other nice
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;;; things. It is currently available from the PAL
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;; (wuarchive.wustl.edu:/languages/ada) as ada-mode-1.06a.tar.Z.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;; The probably very first Ada mode (called electric-ada.el) was
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;;; written by Steven D. Litvintchouk and Steven M. Rosen for the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;;; Gosling Emacs. L. Slater based his development on ada.el and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;;; electric-ada.el.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
73 ;;; A complete rewrite by M. Heritsch and R. Ebert has been done.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
74 ;;; Some ideas from the Ada mode mailing list have been
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;;; added. Some of the functionality of L. Slater's mode has not
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;;; (yet) been recoded in this new mode. Perhaps you prefer sticking
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;;; to his version.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
79 ;;; A complete rewrite for Emacs-20 / Gnat-3.11 has been done by Ada Core
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
80 ;;; Technologies. Please send bugs to briot@gnat.com
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
81
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
82 ;;; Credits:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
83 ;;; Many thanks to John McCabe <john@assen.demon.co.uk> for sending so
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
84 ;;; many patches included in this package.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
85 ;;; Christian Egli <Christian.Egli@hcsd.hac.com>:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
86 ;;; ada-imenu-generic-expression
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
87 ;;; Many thanks also to the following persons that have contributed one day
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
88 ;;; to the ada-mode
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
89 ;;; Philippe Waroquiers (PW) <philippe@cfmu.eurocontrol.be> in particular,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
90 ;;; woodruff@stc.llnl.gov (John Woodruff)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
91 ;;; jj@ddci.dk (Jesper Joergensen)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
92 ;;; gse@ocsystems.com (Scott Evans)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
93 ;;; comar@gnat.com (Cyrille Comar)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
94 ;;; stephen.leake@gsfc.nasa.gov (Stephen Leake)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
95 ;;; and others for their valuable hints.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
96
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
97 ;;; Code:
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
98 ;;; Note: Every function in this package is compiler-independent.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
99 ;;; The names start with ada-
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
100 ;;; The variables that the user can edit can all be modified through
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
101 ;;; the customize mode. They are sorted in alphabetical order in this
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
102 ;;; file.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
103
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
104
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
105 ;; this function is needed at compile time
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
106 (eval-and-compile
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
107 (defun ada-check-emacs-version (major minor &optional is-xemacs)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
108 "Returns t if Emacs's version is greater or equal to MAJOR.MINOR.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
109 If IS-XEMACS is non-nil, check for XEmacs instead of Emacs."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
110 (let ((xemacs-running (or (string-match "Lucid" emacs-version)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
111 (string-match "XEmacs" emacs-version))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
112 (and (or (and is-xemacs xemacs-running)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
113 (not (or is-xemacs xemacs-running)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
114 (or (> emacs-major-version major)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
115 (and (= emacs-major-version major)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
116 (>= emacs-minor-version minor)))))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
117
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
118
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
119 ;; We create a constant for that, for efficiency only
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
120 ;; This should be evaluated both at compile time, only a runtime
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
121 (eval-and-compile
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
122 (defconst ada-xemacs (and (boundp 'running-xemacs)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
123 (symbol-value 'running-xemacs))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
124 "Return t if we are using XEmacs."))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
125
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
126 (unless ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
127 (require 'outline))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
128
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
129 (eval-and-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
130 (condition-case nil (require 'find-file) (error nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
131
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
132 ;; This call should not be made in the release that is done for the
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
133 ;; official FSF Emacs, since it does nothing useful for the latest version
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
134 ;; (require 'ada-support)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
135
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
136 (defvar ada-mode-hook nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
137 "*List of functions to call when Ada mode is invoked.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
138 This hook is automatically executed after the ada-mode is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
139 fully loaded.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
140 This is a good place to add Ada environment specific bindings.")
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
141
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
142 (defgroup ada nil
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
143 "Major mode for editing Ada source in Emacs."
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
144 :group 'languages)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
145
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
146 (defcustom ada-auto-case t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
147 "*Non-nil means automatically change case of preceding word while typing.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
148 Casing is done according to `ada-case-keyword', `ada-case-identifier'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
149 and `ada-case-attribute'."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
150 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
151
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
152 (defcustom ada-broken-decl-indent 0
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
153 "*Number of columns to indent a broken declaration.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
154
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
155 An example is :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
156 declare
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
157 A,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
158 >>>>>B : Integer; -- from ada-broken-decl-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
159 :type 'integer :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
160
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
161 (defcustom ada-broken-indent 2
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
162 "*Number of columns to indent the continuation of a broken line.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
163
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
164 An example is :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
165 My_Var : My_Type := (Field1 =>
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
166 >>>>>>>>>Value); -- from ada-broken-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
167 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
168
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
169 (defcustom ada-case-attribute 'ada-capitalize-word
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
170 "*Function to call to adjust the case of Ada attributes.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
171 It may be `downcase-word', `upcase-word', `ada-loose-case-word',
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
172 `ada-capitalize-word' or `ada-no-auto-case'."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
173 :type '(choice (const downcase-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
174 (const upcase-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
175 (const ada-capitalize-word)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
176 (const ada-loose-case-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
177 (const ada-no-auto-case))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
178 :group 'ada)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
180 (defcustom ada-case-exception-file '("~/.emacs_case_exceptions")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
181 "*List of special casing exceptions dictionaries for identifiers.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
182 The first file is the one where new exceptions will be saved by Emacs
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
183 when you call `ada-create-case-exception'.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
184
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
185 These files should contain one word per line, that gives the casing
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
186 to be used for that word in Ada files. Each line can be terminated by
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
187 a comment."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
188 :type '(repeat (file))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
189 :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
190
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
191 (defcustom ada-case-keyword 'downcase-word
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
192 "*Function to call to adjust the case of an Ada keywords.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
193 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
194 `ada-capitalize-word'."
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
195 :type '(choice (const downcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
196 (const upcase-word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
197 (const ada-capitalize-word)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
198 (const ada-loose-case-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
199 (const ada-no-auto-case))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
200 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
201
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
202 (defcustom ada-case-identifier 'ada-loose-case-word
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
203 "*Function to call to adjust the case of an Ada identifier.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
204 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
205 `ada-capitalize-word'."
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
206 :type '(choice (const downcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
207 (const upcase-word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
208 (const ada-capitalize-word)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
209 (const ada-loose-case-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
210 (const ada-no-auto-case))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
211 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
212
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
213 (defcustom ada-clean-buffer-before-saving t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
214 "*Non-nil means remove trailing spaces and untabify the buffer before saving."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
215 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
216
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
217 (defcustom ada-indent 3
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
218 "*Size of Ada indentation.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
219
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
220 An example is :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
221 procedure Foo is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
222 begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
223 >>>>>>>>>>null; -- from ada-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
224 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
225
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
226 (defcustom ada-indent-after-return t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
227 "*Non-nil means automatically indent after RET or LFD."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
228 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
229
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
230 (defcustom ada-indent-align-comments t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
231 "*Non-nil means align comments on previous line comments, if any.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
232 If nil, indentation is calculated as usual.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
233 Note that indentation is calculated only if `ada-indent-comment-as-code' is t.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
234
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
235 For instance:
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
236 A := 1; -- A multi-line comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
237 -- aligned if ada-indent-align-comments is t"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
238 :type 'boolean :group 'ada)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
239
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
240 (defcustom ada-indent-comment-as-code t
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
241 "*Non-nil means indent comment lines as code.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
242 Nil means do not auto-indent comments."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
243 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
244
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
245 (defcustom ada-indent-is-separate t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
246 "*Non-nil means indent 'is separate' or 'is abstract' if on a single line."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
247 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
248
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
249 (defcustom ada-indent-record-rel-type 3
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
250 "*Indentation for 'record' relative to 'type' or 'use'.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
251
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
252 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
253 type A is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
254 >>>>>>>>>>>record -- from ada-indent-record-rel-type"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
255 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
256
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
257 (defcustom ada-indent-renames ada-broken-indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
258 "*Indentation for renames relative to the matching function statement.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
259 If ada-indent-return is null or negative, the indentation is done relative to
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
260 the open parenthesis (if there is no parenthesis, ada-broken-indent is used).
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
261
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
262 An example is:
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
263 function A (B : Integer)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
264 return C; -- from ada-indent-return
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
265 >>>renames Foo; -- from ada-indent-renames"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
266 :type 'integer :group 'ada)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
267
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
268 (defcustom ada-indent-return 0
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
269 "*Indentation for 'return' relative to the matching 'function' statement.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
270 If ada-indent-return is null or negative, the indentation is done relative to
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
271 the open parenthesis (if there is no parenthesis, ada-broken-indent is used).
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
272
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
273 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
274 function A (B : Integer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
275 >>>>>return C; -- from ada-indent-return"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
276 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
277
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
278 (defcustom ada-indent-to-open-paren t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
279 "*Non-nil means indent according to the innermost open parenthesis."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
280 :type 'boolean :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
281
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
282 (defcustom ada-fill-comment-prefix "-- "
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
283 "*Text inserted in the first columns when filling a comment paragraph.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
284 Note: if you modify this variable, you will have to restart the ada-mode to
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
285 reread this variable."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
286 :type 'string :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
287
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
288 (defcustom ada-fill-comment-postfix " --"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
289 "*Text inserted at the end of each line when filling a comment paragraph.
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
290 with `ada-fill-comment-paragraph-postfix'."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
291 :type 'string :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
292
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
293 (defcustom ada-label-indent -4
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
294 "*Number of columns to indent a label.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
295
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
296 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
297 procedure Foo is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
298 begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
299 >>>>>>>>>>>>Label: -- from ada-label-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
300 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
301
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
302 (defcustom ada-language-version 'ada95
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
303 "*Do we program in `ada83' or `ada95'?"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
304 :type '(choice (const ada83) (const ada95)) :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
305
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
306 (defcustom ada-move-to-declaration nil
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
307 "*Non-nil means `ada-move-to-start' moves point to the subprogram declaration,
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
308 not to 'begin'."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
309 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
310
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
311 (defcustom ada-popup-key '[down-mouse-3]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
312 "*Key used for binding the contextual menu.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
313 If nil, no contextual menu is available."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
314 :type 'string :group 'ada)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
315
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
316 (defcustom ada-search-directories
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
317 '("." "$ADA_INCLUDE_PATH" "/usr/adainclude" "/usr/local/adainclude"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
318 "/opt/gnu/adainclude")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
319 "*List of directories to search for Ada files.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
320 See the description for the `ff-search-directories' variable.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
321 Emacs will automatically add the paths defined in your project file, and if you
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
322 are using the GNAT compiler the output of the gnatls command to find where the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
323 runtime really is."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
324 :type '(repeat (choice :tag "Directory"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
325 (const :tag "default" nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
326 (directory :format "%v")))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
327 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
328
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
329 (defcustom ada-stmt-end-indent 0
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
330 "*Number of columns to indent the end of a statement on a separate line.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
331
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
332 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
333 if A = B
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
334 >>>>>>>>>>>then -- from ada-stmt-end-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
335 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
336
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
337 (defcustom ada-tab-policy 'indent-auto
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
338 "*Control the behavior of the TAB key.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
339 Must be one of :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
340 `indent-rigidly' : always adds ada-indent blanks at the beginning of the line.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
341 `indent-auto' : use indentation functions in this file.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
342 `always-tab' : do indent-relative."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
343 :type '(choice (const indent-auto)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
344 (const indent-rigidly)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
345 (const always-tab))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
346 :group 'ada)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
348 (defcustom ada-use-indent ada-broken-indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
349 "*Indentation for the lines in a 'use' statement.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
350
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
351 An example is:
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
352 use Ada.Text_IO,
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
353 >>>>>Ada.Numerics; -- from ada-use-indent"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
354 :type 'integer :group 'ada)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
355
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
356 (defcustom ada-when-indent 3
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
357 "*Indentation for 'when' relative to 'exception' or 'case'.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
358
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
359 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
360 case A is
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
361 >>>>>>>>when B => -- from ada-when-indent"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
362 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
363
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
364 (defcustom ada-with-indent ada-broken-indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
365 "*Indentation for the lines in a 'with' statement.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
366
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
367 An example is:
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
368 with Ada.Text_IO,
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
369 >>>>>Ada.Numerics; -- from ada-with-indent"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
370 :type 'integer :group 'ada)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
371
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
372 (defcustom ada-which-compiler 'gnat
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
373 "*Name of the compiler to use.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
374 This will determine what features are made available through the ada-mode.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
375 The possible choices are :
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
376 `gnat': Use Ada Core Technologies' Gnat compiler. Add some cross-referencing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
377 features
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
378 `generic': Use a generic compiler"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
379 :type '(choice (const gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
380 (const generic))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
381 :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
382
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
383
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 ;;; ---- end of user configurable variables
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
387 (defvar ada-body-suffixes '(".adb")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
388 "List of possible suffixes for Ada body files.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
389 The extensions should include a `.' if needed.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
390
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
391 (defvar ada-spec-suffixes '(".ads")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
392 "List of possible suffixes for Ada spec files.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
393 The extensions should include a `.' if needed.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
394
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
395 (defvar ada-mode-menu (make-sparse-keymap)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
396 "Menu for ada-mode.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
397
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
398 (defvar ada-mode-map (make-sparse-keymap)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
399 "Local keymap used for Ada mode.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
401 (defvar ada-mode-abbrev-table nil
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
402 "Local abbrev table for Ada mode.")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
403
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (defvar ada-mode-syntax-table nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 "Syntax table to be used for editing Ada source code.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
407 (defvar ada-mode-symbol-syntax-table nil
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
408 "Syntax table for Ada, where `_' is a word constituent.")
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
409
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
410 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
411 (defconst ada-83-string-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
412 '("abort" "abs" "accept" "access" "all" "and" "array" "at" "begin"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
413 "body" "case" "constant" "declare" "delay" "delta" "digits" "do"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
414 "else" "elsif" "end" "entry" "exception" "exit" "for" "function"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
415 "generic" "goto" "if" "in" "is" "limited" "loop" "mod" "new"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
416 "not" "null" "of" "or" "others" "out" "package" "pragma" "private"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
417 "procedure" "raise" "range" "record" "rem" "renames" "return"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
418 "reverse" "select" "separate" "subtype" "task" "terminate" "then"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
419 "type" "use" "when" "while" "with" "xor")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
420 "List of Ada keywords.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
421 This variable is used to define `ada-83-keywords' and `ada-95-keywords'"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
422
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
423 (defvar ada-ret-binding nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
424 "Variable to save key binding of RET when casing is activated.")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
425
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
426 (defvar ada-case-exception '()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
427 "Alist of words (entities) that have special casing.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
428
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
429 (defvar ada-lfd-binding nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
430 "Variable to save key binding of LFD when casing is activated.")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
431
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
432 (defvar ada-other-file-alist nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
433 "Variable used by find-file to find the name of the other package.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
434 See `ff-other-file-alist'.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
435
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
436 ;;; ---- Below are the regexp used in this package for parsing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
437
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (defconst ada-83-keywords
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
439 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
440 (concat "\\<" (regexp-opt ada-83-string-keywords t) "\\>"))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
441 "Regular expression for looking at Ada83 keywords.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
443 (defconst ada-95-keywords
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
444 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
445 (concat "\\<" (regexp-opt
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
446 (append
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
447 '("abstract" "aliased" "protected" "requeue"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
448 "tagged" "until")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
449 ada-83-string-keywords) t) "\\>"))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
450 "Regular expression for looking at Ada95 keywords.")
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
451
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
452 (defvar ada-keywords ada-95-keywords
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
453 "Regular expression for looking at Ada keywords.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
455 (defconst ada-ident-re
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
456 "\\(\\sw\\|[_.]\\)+"
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
457 "Regexp matching Ada (qualified) identifiers.")
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
458
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (defvar ada-procedure-start-regexp
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
460 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\(\\(\\sw\\|[_.]\\)+\\)"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 "Regexp used to find Ada procedures/functions.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (defvar ada-package-start-regexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 "^[ \t]*\\(package\\)"
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
465 "Regexp used to find Ada packages.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 ;;; ---- regexps for indentation functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (defvar ada-block-start-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
471 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
472 (concat "\\<\\(" (regexp-opt '("begin" "declare" "else"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
473 "exception" "generic" "loop" "or"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
474 "private" "select" ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
475 "\\|\\(\\(limited\\|abstract\\|tagged\\)[ \t\n]+\\)*record\\)\\>"))
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
476 "Regexp for keywords starting Ada blocks.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (defvar ada-end-stmt-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
479 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
480 (concat "\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
481 ";" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
482 "=>[ \t]*$" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
483 "^[ \t]*separate[ \t]*(\\(\\sw\\|[_.]\\)+)" "\\|"
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
484 "\\<" (regexp-opt '("begin" "declare" "is" "do" "else" "generic"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
485 "loop" "private" "record" "select"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
486 "then abort" "then") t) "\\>" "\\|"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
487 "^[ \t]*" (regexp-opt '("function" "package" "procedure")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
488 t) "\\>\\(\\sw\\|[ \t_.]\\)+\\<is\\>" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
489 "^[ \t]*exception\\>"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
490 "\\)") )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 "Regexp of possible ends for a non-broken statement.
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
492 A new statement starts after these.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
494 (defvar ada-matching-start-re
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
495 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
496 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
497 (regexp-opt
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
498 '("end" "loop" "select" "begin" "case" "do"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
499 "if" "task" "package" "record" "protected") t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
500 "\\>"))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
501 "Regexp used in ada-goto-matching-start.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
502
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
503 (defvar ada-matching-decl-start-re
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
504 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
505 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
506 (regexp-opt
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
507 '("is" "separate" "end" "declare" "if" "new" "begin" "generic" "when") t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
508 "\\>"))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
509 "Regexp used in ada-goto-matching-decl-start.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
510
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (defvar ada-loop-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 "\\<\\(for\\|while\\|loop\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 "Regexp for the start of a loop.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (defvar ada-subprog-start-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
516 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
517 (concat "\\<" (regexp-opt '("accept" "entry" "function" "package" "procedure"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
518 "protected" "task") t) "\\>"))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 "Regexp for the start of a subprogram.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
521 (defvar ada-named-block-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
522 "[ \t]*\\(\\sw\\|_\\)+[ \t]*:[^=]"
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
523 "Regexp of the name of a block or loop.")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
524
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
525 (defvar ada-contextual-menu-on-identifier nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
526 "Set to true when the right mouse button was clicked on an identifier.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
527
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
528 (defvar ada-contextual-menu-last-point nil
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
529 "Position of point just before displaying the menu.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
530 This is a list (point buffer).
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
531 Since `ada-popup-menu' moves the point where the user clicked, the region
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
532 is modified. Therefore no command from the menu knows what the user selected
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
533 before displaying the contextual menu.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
534 To get the original region, restore the point to this position before
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
535 calling `region-end' and `region-beginning'.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
536 Modify this variable if you want to restore the point to another position.")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
537
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
538 (defvar ada-contextual-menu
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
539 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
540 '("Ada"
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
541 ["Goto Declaration/Body"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
542 (ada-call-from-contextual-menu 'ada-point-and-xref)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
543 :included (and (functionp 'ada-point-and-xref)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
544 ada-contextual-menu-on-identifier)]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
545 ["Goto Previous Reference"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
546 (ada-call-from-contextual-menu 'ada-xref-goto-previous-reference)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
547 :included (functionp 'ada-xref-goto-previous-reference)]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
548 ["List References" ada-find-references
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
549 :included ada-contextual-menu-on-identifier]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
550 ["-" nil nil]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
551 ["Other File" ff-find-other-file]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
552 ["Goto Parent Unit" ada-goto-parent]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
553 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
554
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
555 (let ((map (make-sparse-keymap "Ada")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
556 ;; The identifier part
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
557 (if (equal ada-which-compiler 'gnat)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
558 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
559 (define-key-after map [Ref]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
560 '(menu-item "Goto Declaration/Body"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
561 (lambda()(interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
562 (ada-call-from-contextual-menu
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
563 'ada-point-and-xref))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
564 :visible
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
565 (and (functionp 'ada-point-and-xref)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
566 ada-contextual-menu-on-identifier))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
567 t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
568 (define-key-after map [Prev]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
569 '(menu-item "Goto Previous Reference"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
570 (lambda()(interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
571 (ada-call-from-contextual-menu
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
572 'ada-xref-goto-previous-reference))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
573 :visible
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
574 (functionp 'ada-xref-goto-previous-reference))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
575 t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
576 (define-key-after map [List]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
577 '(menu-item "List References"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
578 ada-find-references
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
579 :visible ada-contextual-menu-on-identifier) t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
580 (define-key-after map [-] '("-" nil) t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
581 ))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
582 (define-key-after map [Other] '("Other file" . ff-find-other-file) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
583 (define-key-after map [Parent] '("Goto Parent Unit" . ada-goto-parent)t)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
584 map))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
585 "Defines the menu to use when the user presses the right mouse button.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
586 The variable `ada-contextual-menu-on-identifier' will be set to t before
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
587 displaying the menu if point was on an identifier."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
588 )
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
589
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
590
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
591 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
592 ;; Support for imenu (see imenu.el)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
593 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
594
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
595 (defconst ada-imenu-subprogram-menu-re
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
596 "^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)[ \t\n]*\\([ \t\n]\\|([^)]+)\\)[ \t\n]*\\(return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?is[ \t\n]")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
597
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
598 (defvar ada-imenu-generic-expression
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
599 (list
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
600 (list nil ada-imenu-subprogram-menu-re 2)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
601 (list "*Specs*"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
602 (concat
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
603 "^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
604 "\\("
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
605 "\\([ \t\n]+\\|[ \t\n]*([^)]+)\\)";; parameter list or simple space
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
606 "\\([ \t\n]*return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
607 "\\)?;") 2)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
608 '("*Tasks*" "^[ \t]*task[ \t]+\\(\\(body\\|type\\)[ \t]+\\)?\\(\\(\\sw\\|_\\)+\\)" 3)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
609 '("*Type Defs*" "^[ \t]*\\(sub\\)?type[ \t]+\\(\\(\\sw\\|_\\)+\\)" 2)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
610 '("*Packages*" "^[ \t]*package[ \t]+\\(\\(body[ \t]+\\)?\\(\\sw\\|[_.]\\)+\\)" 1))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
611 "Imenu generic expression for Ada mode.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
612 See `imenu-generic-expression'. This variable will create two submenus, one
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
613 for type and subtype definitions, the other for subprograms declarations.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
614 The main menu will reference the bodies of the subprograms.")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
615
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
616
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
617
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
618 ;;------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
619 ;; Support for compile.el
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
620 ;;------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
621
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
622 (defun ada-compile-mouse-goto-error ()
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
623 "Mouse interface for ada-compile-goto-error."
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
624 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
625 (mouse-set-point last-input-event)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
626 (ada-compile-goto-error (point))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
627 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
628
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
629 (defun ada-compile-goto-error (pos)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
630 "Replaces `compile-goto-error' from compile.el.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
631 If POS is on a file and line location, go to this position. It adds to
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
632 compile.el the capacity to go to a reference in an error message.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
633 For instance, on this line:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
634 foo.adb:61:11: [...] in call to size declared at foo.ads:11
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
635 both file locations can be clicked on and jumped to."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
636 (interactive "d")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
637 (goto-char pos)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
638
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
639 (skip-chars-backward "-a-zA-Z0-9_:./\\")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
640 (cond
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
641 ;; special case: looking at a filename:line not at the beginning of a line
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
642 ((and (not (bolp))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
643 (looking-at
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
644 "\\([-_.a-zA-Z0-9]+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
645 (let ((line (match-string 2))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
646 (error-pos (point-marker))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
647 source)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
648 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
649 (save-restriction
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
650 (widen)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
651 ;; Use funcall so as to prevent byte-compiler warnings
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
652 (set-buffer (funcall (symbol-function 'compilation-find-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
653 (point-marker) (match-string 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
654 "./"))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
655 (if (stringp line)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
656 (goto-line (string-to-number line)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
657 (set 'source (point-marker))))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
658 (funcall (symbol-function 'compilation-goto-locus)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
659 (cons source error-pos))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
660 ))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
661
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
662 ;; otherwise, default behavior
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
663 (t
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
664 (funcall (symbol-function 'compile-goto-error)))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
665 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
666 (recenter))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
667
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
668
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
669 ;;-------------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
670 ;; Grammar related function
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
671 ;; The functions below work with the syntax class of the characters in an Ada
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
672 ;; buffer. Two syntax tables are created, depending on whether we want '_'
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
673 ;; to be considered as part of a word or not.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
674 ;; Some characters may have multiple meanings depending on the context:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
675 ;; - ' is either the beginning of a constant character or an attribute
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
676 ;; - # is either part of a based litteral or a gnatprep statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
677 ;; - " starts a string, but not if inside a constant character.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
678 ;; - ( and ) should be ignored if inside a constant character.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
679 ;; Thus their syntax property is changed automatically, and we can still use
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
680 ;; the standard Emacs functions for sexp (see `ada-in-string-p')
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
681 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
682 ;; On Emacs, this is done through the `syntax-table' text property. The
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
683 ;; modification is done automatically each time the user as typed a new
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
684 ;; character. This is already done in `font-lock-mode' (in
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
685 ;; `font-lock-syntactic-keywords', so we take advantage of the existing
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
686 ;; mechanism. If font-lock-mode is not activated, we do it by hand in
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
687 ;; `ada-after-change-function', thanks to `ada-deactivate-properties' and
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
688 ;; `ada-initialize-properties'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
689 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
690 ;; on XEmacs, the `syntax-table' property does not exist and we have to use a
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
691 ;; slow advice to `parse-partial-sexp' to do the same thing.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
692 ;; When executing parse-partial-sexp, we simply modify the strings before and
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
693 ;; after, so that the special constants '"', '(' and ')' do not interact
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
694 ;; with parse-partial-sexp.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
695 ;; Note: this code is slow and needs to be rewritten as soon as something
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
696 ;; better is available on XEmacs.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
697 ;;-------------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
698
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
699 (defun ada-create-syntax-table ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
700 "Create the two syntax tables use in the Ada mode.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
701 The standard table declares `_' as a symbol constituent, the second one
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
702 declares it as a word constituent."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
703 (interactive)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
704 (set 'ada-mode-syntax-table (make-syntax-table))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
705 (set-syntax-table ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
706
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
707 ;; define string brackets (`%' is alternative string bracket, but
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
708 ;; almost never used as such and throws font-lock and indentation
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
709 ;; off the track.)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
710 (modify-syntax-entry ?% "$" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
711 (modify-syntax-entry ?\" "\"" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
712
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
713 (modify-syntax-entry ?: "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
714 (modify-syntax-entry ?\; "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
715 (modify-syntax-entry ?& "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
716 (modify-syntax-entry ?\| "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
717 (modify-syntax-entry ?+ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
718 (modify-syntax-entry ?* "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
719 (modify-syntax-entry ?/ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
720 (modify-syntax-entry ?= "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
721 (modify-syntax-entry ?< "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
722 (modify-syntax-entry ?> "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
723 (modify-syntax-entry ?$ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
724 (modify-syntax-entry ?\[ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
725 (modify-syntax-entry ?\] "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
726 (modify-syntax-entry ?\{ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
727 (modify-syntax-entry ?\} "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
728 (modify-syntax-entry ?. "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
729 (modify-syntax-entry ?\\ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
730 (modify-syntax-entry ?\' "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
731
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
732 ;; a single hyphen is punctuation, but a double hyphen starts a comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
733 (modify-syntax-entry ?- ". 12" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
734
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
735 ;; See the comment above on grammar related function for the special
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
736 ;; setup for '#'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
737 (if ada-xemacs
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
738 (modify-syntax-entry ?# "<" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
739 (modify-syntax-entry ?# "$" ada-mode-syntax-table))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
740
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
741 ;; and \f and \n end a comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
742 (modify-syntax-entry ?\f "> " ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
743 (modify-syntax-entry ?\n "> " ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
744
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
745 ;; define what belongs in Ada symbols
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
746 (modify-syntax-entry ?_ "_" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
747
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
748 ;; define parentheses to match
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
749 (modify-syntax-entry ?\( "()" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
750 (modify-syntax-entry ?\) ")(" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
751
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
752 (set 'ada-mode-symbol-syntax-table (copy-syntax-table ada-mode-syntax-table))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
753 (modify-syntax-entry ?_ "w" ada-mode-symbol-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
754 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
755
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
756 ;; Support of special characters in XEmacs (see the comments at the beginning
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
757 ;; of the section on Grammar related functions).
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
758
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
759 (if ada-xemacs
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
760 (defadvice parse-partial-sexp (around parse-partial-sexp-protect-constants)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
761 "Handles special character constants and gnatprep statements."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
762 (let (change)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
763 (if (< to from)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
764 (let ((tmp from))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
765 (setq from to to tmp)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
766 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
767 (goto-char from)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
768 (while (re-search-forward "'\\([(\")#]\\)'" to t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
769 (set 'change (cons (list (match-beginning 1)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
770 1
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
771 (match-string 1))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
772 change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
773 (replace-match "'A'"))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
774 (goto-char from)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
775 (while (re-search-forward "\\(#[0-9a-fA-F]*#\\)" to t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
776 (set 'change (cons (list (match-beginning 1)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
777 (length (match-string 1))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
778 (match-string 1))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
779 change))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
780 (replace-match (make-string (length (match-string 1)) ?@))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
781 ad-do-it
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
782 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
783 (while change
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
784 (goto-char (caar change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
785 (delete-char (cadar change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
786 (insert (caddar change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
787 (set 'change (cdr change)))))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
788
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
789 (defun ada-deactivate-properties ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
790 "Deactivate ada-mode's properties handling.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
791 This would be a duplicate of font-lock if both are used at the same time."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
792 (remove-hook 'after-change-functions 'ada-after-change-function t))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
793
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
794 (defun ada-initialize-properties ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
795 "Initialize some special text properties in the whole buffer.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
796 In particular, character constants are said to be strings, #...# are treated
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
797 as numbers instead of gnatprep comments."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
798 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
799 (save-restriction
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
800 (widen)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
801 (goto-char (point-min))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
802 (while (re-search-forward "'.'" nil t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
803 (add-text-properties (match-beginning 0) (match-end 0)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
804 '(syntax-table ("'" . ?\"))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
805 (goto-char (point-min))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
806 (while (re-search-forward "^[ \t]*#" nil t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
807 (add-text-properties (match-beginning 0) (match-end 0)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
808 '(syntax-table (11 . 10))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
809 (set-buffer-modified-p nil)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
810
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
811 ;; Setting this only if font-lock is not set won't work
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
812 ;; if the user activates or deactivates font-lock-mode,
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
813 ;; but will make things faster most of the time
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
814 (make-local-hook 'after-change-functions)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
815 (add-hook 'after-change-functions 'ada-after-change-function nil t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
816 )))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
817
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
818 (defun ada-after-change-function (beg end old-len)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
819 "Called when the region between BEG and END was changed in the buffer.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
820 OLD-LEN indicates what the length of the replaced text was."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
821 (let ((inhibit-point-motion-hooks t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
822 (eol (point)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
823 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
824 (save-match-data
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
825 (beginning-of-line)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
826 (remove-text-properties (point) eol '(syntax-table nil))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
827 (while (re-search-forward "'.'" eol t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
828 (add-text-properties (match-beginning 0) (match-end 0)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
829 '(syntax-table ("'" . ?\"))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
830 (beginning-of-line)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
831 (if (looking-at "^[ \t]*#")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
832 (add-text-properties (match-beginning 0) (match-end 0)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
833 '(syntax-table (11 . 10))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
834 ))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
835
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
836 ;;------------------------------------------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
837 ;; Testing the grammatical context
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
838 ;;------------------------------------------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
839
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
840 (defsubst ada-in-comment-p (&optional parse-result)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
841 "Returns t if inside a comment."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
842 (nth 4 (or parse-result
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
843 (parse-partial-sexp
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
844 (save-excursion (beginning-of-line) (point)) (point)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
845
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
846 (defsubst ada-in-string-p (&optional parse-result)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
847 "Returns t if point is inside a string.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
848 If parse-result is non-nil, use is instead of calling parse-partial-sexp."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
849 (nth 3 (or parse-result
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
850 (parse-partial-sexp
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
851 (save-excursion (beginning-of-line) (point)) (point)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
852
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
853 (defsubst ada-in-string-or-comment-p (&optional parse-result)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
854 "Returns t if inside a comment or string."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
855 (set 'parse-result (or parse-result
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
856 (parse-partial-sexp
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
857 (save-excursion (beginning-of-line) (point)) (point))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
858 (or (ada-in-string-p parse-result) (ada-in-comment-p parse-result)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
859
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
860
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
861 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
862 ;; Contextual menus
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
863 ;; The Ada-mode comes with contextual menus, bound by default to the right
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
864 ;; mouse button.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
865 ;; Add items to this menu by modifying `ada-contextual-menu'. Note that the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
866 ;; variable `ada-contextual-menu-on-identifier' is set automatically to t
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
867 ;; if the mouse button was pressed on an identifier.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
868 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
869
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
870 (defun ada-call-from-contextual-menu (function)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
871 "Execute FUNCTION when called from the contextual menu.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
872 It forces Emacs to change the cursor position."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
873 (interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
874 (funcall function)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
875 (setq ada-contextual-menu-last-point
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
876 (list (point) (current-buffer))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
877
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
878 (defun ada-popup-menu (position)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
879 "Pops up a contextual menu, depending on where the user clicked.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
880 POSITION is the location the mouse was clicked on.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
881 Sets `ada-contextual-menu-last-point' to the current position before
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
882 displaying the menu. When a function from the menu is called, the point is
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
883 where the mouse button was clicked."
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
884 (interactive "e")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
885
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
886 ;; declare this as a local variable, so that the function called
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
887 ;; in the contextual menu does not hide the region in
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
888 ;; transient-mark-mode.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
889 (let ((deactivate-mark nil))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
890 (set 'ada-contextual-menu-last-point
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
891 (list (point) (current-buffer)))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
892 (mouse-set-point last-input-event)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
893
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
894 (setq ada-contextual-menu-on-identifier
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
895 (and (char-after)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
896 (or (= (char-syntax (char-after)) ?w)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
897 (= (char-after) ?_))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
898 (not (ada-in-string-or-comment-p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
899 (save-excursion (skip-syntax-forward "w")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
900 (not (ada-after-keyword-p)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
901 ))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
902 (let (choice)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
903 (if ada-xemacs
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
904 (set 'choice (funcall (symbol-function 'popup-menu)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
905 ada-contextual-menu))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
906 (set 'choice (x-popup-menu position ada-contextual-menu)))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
907 (if choice
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
908 (funcall (lookup-key ada-contextual-menu (vector (car choice))))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
909 (set-buffer (cadr ada-contextual-menu-last-point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
910 (goto-char (car ada-contextual-menu-last-point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
911 ))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
912
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
913
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
914 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
915 ;; Misc functions
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
916 ;;------------------------------------------------------------------
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
917
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
918 ;;;###autoload
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
919 (defun ada-add-extensions (spec body)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
920 "Define SPEC and BODY as being valid extensions for Ada files.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
921 Going from body to spec with `ff-find-other-file' used these
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
922 extensions.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
923 SPEC and BODY are two regular expressions that must match against the file
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
924 name"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
925 (let* ((reg (concat (regexp-quote body) "$"))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
926 (tmp (assoc reg ada-other-file-alist)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
927 (if tmp
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
928 (setcdr tmp (list (cons spec (cadr tmp))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
929 (add-to-list 'ada-other-file-alist (list reg (list spec)))))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
930
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
931 (let* ((reg (concat (regexp-quote spec) "$"))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
932 (tmp (assoc reg ada-other-file-alist)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
933 (if tmp
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
934 (setcdr tmp (list (cons body (cadr tmp))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
935 (add-to-list 'ada-other-file-alist (list reg (list body)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
936
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
937 (add-to-list 'auto-mode-alist (cons spec 'ada-mode))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
938 (add-to-list 'auto-mode-alist (cons body 'ada-mode))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
939
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
940 (add-to-list 'ada-spec-suffixes spec)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
941 (add-to-list 'ada-body-suffixes body)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
942
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
943 ;; Support for speedbar (Specifies that we want to see these files in
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
944 ;; speedbar)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
945 (condition-case nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
946 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
947 (require 'speedbar)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
948 (funcall (symbol-function 'speedbar-add-supported-extension)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
949 spec)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
950 (funcall (symbol-function 'speedbar-add-supported-extension)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
951 body)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
952 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
953
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
954
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
955 ;;;###autoload
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (defun ada-mode ()
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
957 "Ada mode is the major mode for editing Ada code.
10705
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 Bindings are as follows: (Note: 'LFD' is control-j.)
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 Indent line '\\[ada-tab]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 Indent line, insert newline and indent the new line. '\\[newline-and-indent]'
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 Re-format the parameter-list point is in '\\[ada-format-paramlist]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 Indent all lines in region '\\[ada-indent-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 Adjust case of identifiers and keywords in region '\\[ada-adjust-case-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 Adjust case of identifiers and keywords in buffer '\\[ada-adjust-case-buffer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
970 Fill comment paragraph, justify and append postfix '\\[fill-paragraph]'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
972 Next func/proc/task '\\[ada-next-procedure]' Previous func/proc/task '\\[ada-previous-procedure]'
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
973 Next package '\\[ada-next-package]' Previous package '\\[ada-previous-package]'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 Goto matching start of current 'end ...;' '\\[ada-move-to-start]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 Goto end of current block '\\[ada-move-to-end]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 Comments are handled using standard GNU Emacs conventions, including:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 Start a comment '\\[indent-for-comment]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 Comment region '\\[comment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 Uncomment region '\\[ada-uncomment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 Continue comment on next line '\\[indent-new-comment-line]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 If you use imenu.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 Display index-menu of functions & procedures '\\[imenu]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 If you use find-file.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 Switch to other file (Body <-> Spec) '\\[ff-find-other-file]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 or '\\[ff-mouse-find-other-file]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 Switch to other file in other window '\\[ada-ff-other-window]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 or '\\[ff-mouse-find-other-file-other-window]
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
992 If you use this function in a spec and no body is available, it gets created with body stubs.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 If you use ada-xref.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 Goto declaration: '\\[ada-point-and-xref]' on the identifier
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 or '\\[ada-goto-declaration]' with point on the identifier
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
997 Complete identifier: '\\[ada-complete-identifier]'."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 (kill-all-local-variables)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1002 (set (make-local-variable 'require-final-newline) t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 (make-local-variable 'comment-start)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1005 (if ada-fill-comment-prefix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1006 (set 'comment-start ada-fill-comment-prefix)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1007 (set 'comment-start "-- "))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1008
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1009 ;; Set the paragraph delimiters so that one can select a whole block
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1010 ;; simply with M-h
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1011 (set (make-local-variable 'paragraph-start) "[ \t\n\f]*$")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1012 (set (make-local-variable 'paragraph-separate) "[ \t\n\f]*$")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 ;; 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
1015 ;; this buffer had been in another mode before. RE
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1016 (set (make-local-variable 'comment-end) "")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1017
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1018 ;; used by autofill and indent-new-comment-line
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1019 (set (make-local-variable 'comment-start-skip) "---*[ \t]*")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1020
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1021 ;; used by autofill to break a comment line and continue it on another line.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1022 ;; The reason we need this one is that the default behavior does not work
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1023 ;; correctly with the definition of paragraph-start above when the comment
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1024 ;; is right after a multi-line subprogram declaration (the comments are
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1025 ;; aligned under the latest parameter, not under the declaration start).
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1026 (set (make-local-variable 'comment-line-break-function)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1027 (lambda (&optional soft) (let ((fill-prefix nil))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1028 (indent-new-comment-line soft))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1029
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1030 (set (make-local-variable 'indent-line-function)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1031 'ada-indent-current-function)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1032
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1033 (set (make-local-variable 'comment-column) 40)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1034
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1035 ;; Emacs 20.3 defines a comment-padding to insert spaces between
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1036 ;; the comment and the text. We do not want any, this is already
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1037 ;; included in comment-start
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1038 (unless ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1039 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1040 (if (ada-check-emacs-version 20 3)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1041 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1042 (set (make-local-variable 'parse-sexp-ignore-comments) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1043 (set (make-local-variable 'comment-padding) 0)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1044 (set (make-local-variable 'parse-sexp-lookup-properties) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1045 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1046
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1047 (set 'case-fold-search t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1048 (if (boundp 'imenu-case-fold-search)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1049 (set 'imenu-case-fold-search t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1050
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1051 (set (make-local-variable 'fill-paragraph-function)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1052 'ada-fill-comment-paragraph)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1053
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1054 (set (make-local-variable 'imenu-generic-expression)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1055 ada-imenu-generic-expression)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1056
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1057 ;; Support for compile.el
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1058 ;; We just substitute our own functions to go to the error.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1059 (add-hook 'compilation-mode-hook
28995
93c16141d107 (ada-mode, ada-create-case-exception): Don't quote lambdas.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26225
diff changeset
1060 (lambda()
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1061 (set 'compile-auto-highlight 40)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1062 (define-key compilation-minor-mode-map [mouse-2]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1063 'ada-compile-mouse-goto-error)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1064 (define-key compilation-minor-mode-map "\C-c\C-c"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1065 'ada-compile-goto-error)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1066 (define-key compilation-minor-mode-map "\C-m"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1067 'ada-compile-goto-error)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1068 ))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1069
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1070 ;; font-lock support :
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1071 ;; We need to set some properties for XEmacs, and define some variables
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1072 ;; for Emacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1073
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1074 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1075 ;; XEmacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1076 (put 'ada-mode 'font-lock-defaults
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1077 '(ada-font-lock-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1078 nil t ((?\_ . "w") (?# . ".")) beginning-of-line))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1079 ;; Emacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1080 (set (make-local-variable 'font-lock-defaults)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1081 '(ada-font-lock-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1082 nil t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1083 ((?\_ . "w") (?# . "."))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1084 beginning-of-line
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1085 (font-lock-syntactic-keywords . ada-font-lock-syntactic-keywords)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1086 )
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1087
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1088 ;; Set up support for find-file.el.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1089 (set (make-variable-buffer-local 'ff-other-file-alist)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1090 'ada-other-file-alist)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1091 (set (make-variable-buffer-local 'ff-search-directories)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1092 'ada-search-directories)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1093 (setq ff-post-load-hooks 'ada-set-point-accordingly
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1094 ff-file-created-hooks 'ada-make-body)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1095 (add-hook 'ff-pre-load-hooks 'ada-which-function-are-we-in)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1096
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1097 ;; Some special constructs for find-file.el
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1098 ;; We do not need to add the construction for 'with', which is in the
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1099 ;; standard find-file.el
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1100 (make-local-variable 'ff-special-constructs)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1101
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1102 ;; Go to the parent package :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1103 (add-to-list 'ff-special-constructs
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1104 (cons (eval-when-compile
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1105 (concat "^\\(private[ \t]\\)?[ \t]*package[ \t]+"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1106 "\\(body[ \t]+\\)?"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1107 "\\(\\(\\sw\\|[_.]\\)+\\)\\.\\(\\sw\\|_\\)+[ \t\n]+is"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1108 (lambda ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1109 (set 'fname (ff-get-file
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1110 ada-search-directories
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1111 (ada-make-filename-from-adaname
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1112 (match-string 3))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1113 ada-spec-suffixes)))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1114 ;; Another special construct for find-file.el : when in a separate clause,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1115 ;; go to the correct package.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1116 (add-to-list 'ff-special-constructs
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1117 (cons "^separate[ \t\n]*(\\(\\(\\sw\\|[_.]\\)+\\))"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1118 (lambda ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1119 (set 'fname (ff-get-file
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1120 ada-search-directories
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1121 (ada-make-filename-from-adaname
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1122 (match-string 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1123 ada-spec-suffixes)))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1124 ;; Another special construct, that redefines the one in find-file.el. The
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1125 ;; old one can handle only one possible type of extension for Ada files
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1126 ;; remove from the list the standard "with..." that is put by find-file.el,
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1127 ;; since it uses the old ada-spec-suffix variable
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1128 ;; This one needs to replace the standard one defined in find-file.el (with
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1129 ;; Emacs <= 20.4), since that one uses the old variable ada-spec-suffix
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1130 (let ((old-construct
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1131 (assoc "^with[ \t]+\\([a-zA-Z0-9_\\.]+\\)" ff-special-constructs))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1132 (new-cdr
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1133 (lambda ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1134 (set 'fname (ff-get-file
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1135 ada-search-directories
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1136 (ada-make-filename-from-adaname
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1137 (match-string 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1138 ada-spec-suffixes)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1139 (if old-construct
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1140 (setcdr old-construct new-cdr)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1141 (add-to-list 'ff-special-constructs
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1142 (cons "^with[ \t]+\\([a-zA-Z0-9_\\.]+\\)"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1143 new-cdr))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1144
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1145 ;; Support for outline-minor-mode
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1146 (set (make-local-variable 'outline-regexp)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1147 "\\([ \t]*\\(procedure\\|function\\|package\\|if\\|while\\|for\\|declare\\|case\\|end\\|begin\\|loop\\)\\|--\\)")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1148 (set (make-local-variable 'outline-level) 'ada-outline-level)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1149
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1150 ;; Support for imenu : We want a sorted index
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1151 (set 'imenu-sort-function 'imenu--sort-by-name)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1152
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1153 ;; Support for which-function-mode is provided in ada-support (support
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1154 ;; for nested subprograms)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1155
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1156 ;; Set up the contextual menu
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1157 (if ada-popup-key
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1158 (define-key ada-mode-map ada-popup-key 'ada-popup-menu))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1159
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1160 ;; Support for Abbreviations (the user still need to "M-x abbrev-mode"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1161 (define-abbrev-table 'ada-mode-abbrev-table ())
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1162 (set 'local-abbrev-table ada-mode-abbrev-table)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1163
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1164 ;; Support for indent-new-comment-line (Especially for XEmacs)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1165 (set 'comment-multi-line nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1166 (defconst comment-indent-function (lambda () comment-column))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1167
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1168 (set 'major-mode 'ada-mode)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1169 (set 'mode-name "Ada")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 (use-local-map ada-mode-map)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1173 (if ada-xemacs
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1174 (funcall (symbol-function 'easy-menu-add)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1175 ada-mode-menu ada-mode-map))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1176
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1177 (set-syntax-table ada-mode-syntax-table)
10705
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 (if ada-clean-buffer-before-saving
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1181 ;; remove all spaces at the end of lines in the whole buffer.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1182 (add-hook 'local-write-file-hooks 'ada-remove-trailing-spaces)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1183 ;; convert all tabs to the correct number of spaces.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1184 (add-hook 'local-write-file-hooks
28995
93c16141d107 (ada-mode, ada-create-case-exception): Don't quote lambdas.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26225
diff changeset
1185 (lambda () (untabify (point-min) (point-max))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 (run-hooks 'ada-mode-hook)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1189 ;; Run this after the hook to give the users a chance to activate
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1190 ;; font-lock-mode
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1191
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1192 (unless ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1193 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1194 (ada-initialize-properties)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1195 (make-local-hook 'font-lock-mode-hook)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1196 (add-hook 'font-lock-mode-hook 'ada-deactivate-properties nil t)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1197
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 ;; the following has to be done after running the ada-mode-hook
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 ;; because users might want to set the values of these variable
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 ;; inside the hook (MH)
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 (cond ((eq ada-language-version 'ada83)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1203 (set 'ada-keywords ada-83-keywords))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1204 ((eq ada-language-version 'ada95)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1205 (set 'ada-keywords ada-95-keywords)))
10705
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 (if ada-auto-case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 (ada-activate-keys-for-case)))
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
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1211 ;;-----------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1212 ;; auto-casing
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1213 ;; Since Ada is case-insensitive, the Ada-mode provides an extensive set of
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1214 ;; functions to auto-case identifiers, keywords, ...
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1215 ;; The basic rules for autocasing are defined through the variables
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1216 ;; `ada-case-attribute', `ada-case-keyword' and `ada-case-identifier'. These
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1217 ;; are references to the functions that will do the actual casing.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1218 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1219 ;; However, in most cases, the user will want to define some exceptions to
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1220 ;; these casing rules. This is done through a list of files, that contain
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1221 ;; one word per line. These files are stored in `ada-case-exception-file'.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1222 ;; For backward compatibility, this variable can also be a string.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1223 ;;-----------------------------------------------------------------
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1224
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1225 (defun ada-create-case-exception (&optional word)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1226 "Defines WORD as an exception for the casing system.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1227 If WORD is not given, then the current word in the buffer is used instead.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1228 The new words is added to the first file in `ada-case-exception-file'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1229 The standard casing rules will no longer apply to this word."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1231 (let ((previous-syntax-table (syntax-table))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1232 (exception-list '())
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1233 file-name
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1234 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1235
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1236 (cond ((stringp ada-case-exception-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1237 (set 'file-name ada-case-exception-file))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1238 ((listp ada-case-exception-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1239 (set 'file-name (car ada-case-exception-file)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1240 (t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1241 (error "No exception file specified")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1242
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1243 (set-syntax-table ada-mode-symbol-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1244 (unless word
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1245 (save-excursion
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1246 (skip-syntax-backward "w")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1247 (set 'word (buffer-substring-no-properties
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1248 (point) (save-excursion (forward-word 1) (point))))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1249
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1250 ;; Reread the exceptions file, in case it was modified by some other,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1251 ;; and to keep the end-of-line comments that may exist in it.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1252 (if (file-readable-p (expand-file-name file-name))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1253 (let ((buffer (current-buffer)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1254 (find-file (expand-file-name file-name))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1255 (set-syntax-table ada-mode-symbol-syntax-table)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1256 (widen)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1257 (goto-char (point-min))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1258 (while (not (eobp))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1259 (add-to-list 'exception-list
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1260 (list
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1261 (buffer-substring-no-properties
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1262 (point) (save-excursion (forward-word 1) (point)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1263 (buffer-substring-no-properties
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1264 (save-excursion (forward-word 1) (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1265 (save-excursion (end-of-line) (point)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1266 t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1267 (forward-line 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1268 (kill-buffer nil)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1269 (set-buffer buffer)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1270
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1271 ;; If the word is already in the list, even with a different casing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1272 ;; we simply want to replace it.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1273 (if (and (not (equal exception-list '()))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1274 (assoc-ignore-case word exception-list))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1275 (setcar (assoc-ignore-case word exception-list)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1276 word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1277 (add-to-list 'exception-list (list word "" t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1278 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1279
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1280 (if (and (not (equal ada-case-exception '()))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1281 (assoc-ignore-case word ada-case-exception))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1282 (setcar (assoc-ignore-case word ada-case-exception)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1283 word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1284 (add-to-list 'ada-case-exception (cons word t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1285 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1286
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1287 ;; Save the list in the file
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1288 (find-file (expand-file-name file-name))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1289 (erase-buffer)
28995
93c16141d107 (ada-mode, ada-create-case-exception): Don't quote lambdas.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26225
diff changeset
1290 (mapcar (lambda (x) (insert (car x) (nth 1 x) "\n"))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1291 (sort exception-list
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1292 (lambda(a b) (string< (car a) (car b)))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1293 (save-buffer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1294 (kill-buffer nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1295 (set-syntax-table previous-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1296 ))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1297
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1298 (defun ada-case-read-exceptions-from-file (file-name)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1299 "Read the content of the casing exception file FILE-NAME."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1300 (if (file-readable-p (expand-file-name file-name))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1301 (let ((buffer (current-buffer)))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1302 (find-file (expand-file-name file-name))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1303 (set-syntax-table ada-mode-symbol-syntax-table)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1304 (widen)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1305 (goto-char (point-min))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1306 (while (not (eobp))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1307
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1308 ;; If the item is already in the list, even with an other casing,
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1309 ;; do not add it again. This way, the user can easily decide which
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1310 ;; priority should be applied to each casing exception
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1311 (let ((word (buffer-substring-no-properties
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1312 (point) (save-excursion (forward-word 1) (point)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1313 (unless (assoc-ignore-case word ada-case-exception)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1314 (add-to-list 'ada-case-exception (cons word t))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1315
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1316 (forward-line 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1317 (kill-buffer nil)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1318 (set-buffer buffer)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1319 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1320
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1321 (defun ada-case-read-exceptions ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1322 "Read all the casing exception files from `ada-case-exception-file'."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1323 (interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1324
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1325 ;; Reinitialize the casing exception list
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1326 (set 'ada-case-exception '())
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1327
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1328 (cond ((stringp ada-case-exception-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1329 (ada-case-read-exceptions-from-file ada-case-exception-file))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1330
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1331 ((listp ada-case-exception-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1332 (mapcar 'ada-case-read-exceptions-from-file
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1333 ada-case-exception-file))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1334
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1335 (defun ada-adjust-case-identifier ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1336 "Adjust case of the previous identifier.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1337 The auto-casing is done according to the value of `ada-case-identifier' and
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1338 the exceptions defined in `ada-case-exception-file'."
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1339 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1340 (if (or (equal ada-case-exception '())
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1341 (equal (char-after) ?_))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1342 (funcall ada-case-identifier -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1343
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1344 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1345 (let ((end (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1346 (start (save-excursion (skip-syntax-backward "w")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1347 (point)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1348 match)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1349 ;; If we have an exception, replace the word by the correct casing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1350 (if (set 'match (assoc-ignore-case (buffer-substring start end)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1351 ada-case-exception))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1352
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1353 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1354 (delete-region start end)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1355 (insert (car match)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1356
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1357 ;; Else simply re-case the word
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1358 (funcall ada-case-identifier -1))))))
10705
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 (defun ada-after-keyword-p ()
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1361 "Returns t if cursor is after a keyword that is not an attribute."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 (forward-word -1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1364 (and (not (and (char-before)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1365 (or (= (char-before) ?_)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1366 (= (char-before) ?'))));; unless we have a _ or '
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 (looking-at (concat ada-keywords "[^_]")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (defun ada-adjust-case (&optional force-identifier)
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1370 "Adjust the case of the word before the just typed character.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1371 If FORCE-IDENTIFIER is non-nil then also adjust keyword as identifier."
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1372 (forward-char -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1373 (if (and (> (point) 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1374 ;; or if at the end of a character constant
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1375 (not (and (eq (char-after) ?')
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1376 (eq (char-before (1- (point))) ?')))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1377 ;; or if the previous character was not part of a word
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1378 (eq (char-syntax (char-before)) ?w)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1379 ;; if in a string or a comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1380 (not (ada-in-string-or-comment-p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1381 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1382 (if (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1383 (forward-word -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1384 (or (= (point) (point-min))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1385 (backward-char 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1386 (= (char-after) ?'))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1387 (funcall ada-case-attribute -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1388 (if (and
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1389 (not force-identifier) ; (MH)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1390 (ada-after-keyword-p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1391 (funcall ada-case-keyword -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1392 (ada-adjust-case-identifier))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1393 (forward-char 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1394 )
10705
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 (defun ada-adjust-case-interactive (arg)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1397 "Adjust the case of the previous word, and process the character just typed.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1398 ARG is the prefix the user entered with \C-u."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 (interactive "P")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1400
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1401 (if ada-auto-case
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1402 (let ((lastk last-command-char)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1403 (previous-syntax-table (syntax-table)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1404
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1405 (unwind-protect
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1406 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1407 (set-syntax-table ada-mode-symbol-syntax-table)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1408 (cond ((or (eq lastk ?\n)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1409 (eq lastk ?\r))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1410 ;; horrible kludge
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1411 (insert " ")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1412 (ada-adjust-case)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1413 ;; horrible dekludge
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1414 (delete-backward-char 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1415 ;; some special keys and their bindings
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1416 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1417 ((eq lastk ?\n)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1418 (funcall ada-lfd-binding))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1419 ((eq lastk ?\r)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1420 (funcall ada-ret-binding))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1421 ((eq lastk ?\C-i) (ada-tab))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1422 ;; Else just insert the character
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1423 ((self-insert-command (prefix-numeric-value arg))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1424 ;; if there is a keyword in front of the underscore
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1425 ;; then it should be part of an identifier (MH)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1426 (if (eq lastk ?_)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1427 (ada-adjust-case t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1428 (ada-adjust-case))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1429 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1430 ;; Restore the syntax table
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1431 (set-syntax-table previous-syntax-table))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1432 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1433
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1434 ;; Else, no auto-casing
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1435 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1436 ((eq last-command-char ?\n)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1437 (funcall ada-lfd-binding))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1438 ((eq last-command-char ?\r)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1439 (funcall ada-ret-binding))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1440 (t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1441 (self-insert-command (prefix-numeric-value arg))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1442 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1444 (defun ada-activate-keys-for-case ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1445 "Modifies the key bindings for all the keys that should readjust the casing."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1446 (interactive)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1447 ;; Save original key-bindings to allow swapping ret/lfd
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1448 ;; when casing is activated.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1449 ;; The 'or ...' is there to be sure that the value will not
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1450 ;; be changed again when Ada mode is called more than once
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1451 (or ada-ret-binding (set 'ada-ret-binding (key-binding "\C-M")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1452 (or ada-lfd-binding (set 'ada-lfd-binding (key-binding "\C-j")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1453
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1454 ;; Call case modifying function after certain keys.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 (mapcar (function (lambda(key) (define-key
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 ada-mode-map
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 (char-to-string key)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 'ada-adjust-case-interactive)))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1459 '( ?` ?_ ?# ?% ?& ?* ?( ?) ?- ?= ?+
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1460 ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?/ ?\n 32 ?\r )))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 (defun ada-loose-case-word (&optional arg)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1463 "Upcase first letter and letters following `_' in the following word.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1464 No other letter is modified.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1465 ARG is ignored, and is there for compatibility with `capitalize-word' only."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1466 (interactive)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1467 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1468 (let ((end (save-excursion (skip-syntax-forward "w") (point)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1469 (first t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1470 (skip-syntax-backward "w")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1471 (while (and (or first (search-forward "_" end t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1472 (< (point) end))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1473 (and first
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1474 (set 'first nil))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1475 (insert-char (upcase (following-char)) 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1476 (delete-char 1)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1477
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1478 (defun ada-no-auto-case (&optional arg)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1479 "Does nothing.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1480 This function can be used for the auto-casing variables in the ada-mode, to
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1481 adapt to unusal auto-casing schemes. Since it does nothing, you can for
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1482 instance use it for `ada-case-identifier' if you don't want any special
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1483 auto-casing for identifiers, whereas keywords have to be lower-cased.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1484 See also `ada-auto-case' to disable auto casing altogether."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1485 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1487 (defun ada-capitalize-word (&optional arg)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1488 "Upcase first letter and letters following '_', lower case other letters.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1489 ARG is ignored, and is there for compatibility with `capitalize-word' only."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1490 (interactive)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1491 (let ((end (save-excursion (skip-syntax-forward "w") (point)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1492 (begin (save-excursion (skip-syntax-backward "w") (point))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1493 (modify-syntax-entry ?_ "_")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1494 (capitalize-region begin end)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1495 (modify-syntax-entry ?_ "w")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 (defun ada-adjust-case-region (from to)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1498 "Adjusts the case of all words in the region between FROM and TO.
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1499 Attention: This function might take very long for big regions !"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 (keywordp nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1504 (attribp nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1505 (previous-syntax-table (syntax-table)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1506 (message "Adjusting case ...")
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1507 (unwind-protect
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1508 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1509 (set-syntax-table ada-mode-symbol-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1510 (goto-char to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1511 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1512 ;; loop: look for all identifiers, keywords, and attributes
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1513 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1514 (while (re-search-backward "\\<\\(\\sw+\\)\\>" from t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1515 (set 'end (match-end 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1516 (set 'attribp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1517 (and (> (point) from)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1518 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1519 (forward-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1520 (set 'attribp (looking-at "'.[^']")))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1521 (or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1522 ;; do nothing if it is a string or comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1523 (ada-in-string-or-comment-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1524 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1525 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1526 ;; get the identifier or keyword or attribute
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1527 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1528 (set 'begin (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1529 (set 'keywordp (looking-at ada-keywords))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1530 (goto-char end)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1531 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1532 ;; casing according to user-option
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1533 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1534 (if attribp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1535 (funcall ada-case-attribute -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1536 (if keywordp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1537 (funcall ada-case-keyword -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1538 (ada-adjust-case-identifier)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1539 (goto-char begin))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1540 (message "Adjusting case ... Done"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1541 (set-syntax-table previous-syntax-table))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 (defun ada-adjust-case-buffer ()
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1544 "Adjusts the case of all words in the whole buffer.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545 ATTENTION: This function might take very long for big buffers !"
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1546 (interactive "*")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 (ada-adjust-case-region (point-min) (point-max)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1550 ;;--------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1551 ;; Format Parameter Lists
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1552 ;; Some special algorithms are provided to indent the parameter lists in
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1553 ;; subprogram declarations. This is done in two steps:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1554 ;; - First parses the parameter list. The returned list has the following
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1555 ;; format:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1556 ;; ( (<Param_Name> in? out? access? <Type_Name> <Default_Expression>)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1557 ;; ... )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1558 ;; This is done in `ada-scan-paramlist'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1559 ;; - Delete and recreate the parameter list in function
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1560 ;; `ada-insert-paramlist'.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1561 ;; Both steps are called from `ada-format-paramlist'.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1562 ;; Note: Comments inside the parameter list are lost.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1563 ;; The syntax has to be correct, or the reformating will fail.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1564 ;;--------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1565
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 (defun ada-format-paramlist ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1567 "Reformats the parameter list point is in."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 (delend nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1572 (paramlist nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1573 (previous-syntax-table (syntax-table)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1574 (unwind-protect
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1575 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1576 (set-syntax-table ada-mode-symbol-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1577
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1578 ;; check if really inside parameter list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1579 (or (ada-in-paramlist-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1580 (error "not in parameter list"))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1581
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1582 ;; find start of current parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1583 (ada-search-ignore-string-comment
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1584 (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1585 (down-list 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1586 (backward-char 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1587 (set 'begin (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1588
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1589 ;; find end of parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1590 (forward-sexp 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1591 (set 'delend (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1592 (delete-char -1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1593 (insert "\n")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1594
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1595 ;; find end of last parameter-declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1596 (forward-comment -1000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1597 (set 'end (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1598
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1599 ;; build a list of all elements of the parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1600 (set 'paramlist (ada-scan-paramlist (1+ begin) end))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1601
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1602 ;; delete the original parameter-list
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1603 (delete-region begin delend)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1604
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1605 ;; insert the new parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1606 (goto-char begin)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1607 (ada-insert-paramlist paramlist))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1608
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1609 ;; restore syntax-table
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1610 (set-syntax-table previous-syntax-table)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1611 )))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 (defun ada-scan-paramlist (begin end)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1614 "Scan the parameter list found in between BEGIN and END.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1615 Returns the equivalent internal parameter list."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 (let ((paramlist (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 (param (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 (notend t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 (apos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620 (epos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621 (semipos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 (goto-char begin)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1625
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626 ;; loop until end of last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627 (while notend
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 ;; find first character of parameter-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1631 (set 'apos (point))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1633 ;; find last character of parameter-declaration
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1634 (if (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1635 (ada-search-ignore-string-comment "[ \t\n]*;" nil end t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1637 (set 'epos (car match-cons))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1638 (set 'semipos (cdr match-cons)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1639 (set 'epos end))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1641 ;; read name(s) of parameter(s)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1642 (goto-char apos)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1643 (looking-at "\\(\\(\\sw\\|[_, \t\n]\\)*\\(\\sw\\|_\\)\\)[ \t\n]*:[^=]")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1644
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1645 (set 'param (list (match-string 1)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1646 (ada-search-ignore-string-comment ":" nil epos t 'search-forward)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1647
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1648 ;; look for 'in'
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1649 (set 'apos (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1650 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1651 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1652 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1653 (consp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1654 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1655 "in" nil epos t 'word-search-forward)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1656
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 ;; look for 'out'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1658 (goto-char apos)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1659 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1660 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1661 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1662 (consp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1663 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1664 "out" nil epos t 'word-search-forward)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1666 ;; look for 'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 (goto-char apos)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1668 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1669 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1670 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1671 (consp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1672 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1673 "access" nil epos t 'word-search-forward)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1675 ;; skip 'in'/'out'/'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 (ada-goto-next-non-ws)
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1678 (while (looking-at "\\<\\(in\\|out\\|access\\)\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 (ada-goto-next-non-ws))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1682 ;; read type of parameter
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1683 ;; We accept spaces in the name, since some software like Rose
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1684 ;; generates something like: "A : B 'Class"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1685 (looking-at "\\<\\(\\sw\\|[_.' \t]\\)+\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1686 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1687 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1688 (list (match-string 0))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690 ;; read default-expression, if there is one
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1691 (goto-char (set 'apos (match-end 0)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1692 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1693 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1694 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1695 (if (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1696 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1697 ":=" nil epos t 'search-forward))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1698 (buffer-substring (car match-cons) epos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1699 nil))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1700
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 ;; add this parameter-declaration to the list
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1702 (set 'paramlist (append paramlist (list param)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 ;; check if it was the last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 (if (eq epos end)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1706 (set 'notend nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 (goto-char semipos))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1708 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 (reverse paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711 (defun ada-insert-paramlist (paramlist)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1712 "Inserts a formatted PARAMLIST in the buffer."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713 (let ((i (length paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 (parlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1715 (typlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1716 (inp nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1717 (outp nil)
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1718 (accessp nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 (column nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 (firstcol nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1722 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1723 (while (not (zerop i))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1724 (set 'i (1- i))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1725
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 ;; get max length of parameter-name
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1727 (set 'parlen (max parlen (length (nth 0 (nth i paramlist)))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1728
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1729 ;; get max length of type-name
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1730 (set 'typlen (max typlen (length (nth 4 (nth i paramlist)))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1731
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732 ;; is there any 'in' ?
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1733 (set 'inp (or inp (nth 1 (nth i paramlist))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1734
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735 ;; is there any 'out' ?
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1736 (set 'outp (or outp (nth 2 (nth i paramlist))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1737
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1738 ;; is there any 'access' ?
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1739 (set 'accessp (or accessp (nth 3 (nth i paramlist))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1740 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1741
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742 ;; does paramlist already start on a separate line ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744 (re-search-backward "^.\\|[^ \t]" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 (looking-at "^."))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 ;; yes => re-indent it
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1747 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1748 (ada-indent-current)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1749 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1750 (if (looking-at "\\(is\\|return\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1751 (replace-match " \\1"))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1752
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1753 ;; no => insert it where we are after removing any whitespace
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1754 (fixup-whitespace)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1755 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1756 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1757 ((looking-at "[ \t]*\\(\n\\|;\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1758 (replace-match "\\1"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1759 ((looking-at "[ \t]*\\(is\\|return\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1760 (replace-match " \\1"))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1761 (insert " "))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 (insert "(")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1764 (ada-indent-current)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1765
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1766 (set 'firstcol (current-column))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1767 (set 'i (length paramlist))
10705
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 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770 (while (not (zerop i))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1771 (set 'i (1- i))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1772 (set 'column firstcol)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 ;; insert parameter-name, space and colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 (insert (nth 0 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 (indent-to (+ column parlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 (insert ": ")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1778 (set 'column (current-column))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1780 ;; insert 'in' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 (if (nth 1 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782 (insert "in ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1784 (or inp
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1785 accessp)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 (insert " ")))
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 ;; insert 'out' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 (if (nth 2 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 (insert "out ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (or outp
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1794 accessp)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 (insert " ")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1798 ;; insert 'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 (if (nth 3 (nth i paramlist))
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1800 (insert "access "))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1802 (set 'column (current-column))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 ;; insert type-name and, if necessary, space and default-expression
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 (insert (nth 4 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (if (nth 5 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 (indent-to (+ column typlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (insert (nth 5 (nth i paramlist)))))
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 ;; check if it was the last parameter
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1812 (if (zerop i)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1813 (insert ")")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1814 ;; no => insert ';' and newline and indent
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1815 (insert ";")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1816 (newline)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1817 (indent-to firstcol))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1818 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1819
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1820 ;; if anything follows, except semicolon, newline, is or return
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 ;; put it in a new line and indent it
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1822 (unless (looking-at "[ \t]*\\(;\\|\n\\|is\\|return\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1823 (ada-indent-newline-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1828 ;;;----------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1829 ;; Indentation Engine
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1830 ;; All indentations are indicated as a two-element string:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1831 ;; - position of reference in the buffer
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1832 ;; - offset to indent from this position (can also be a symbol or a list
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1833 ;; that are evaluated)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1834 ;; Thus the total indentation for a line is the column number of the reference
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1835 ;; position plus whatever value the evaluation of the second element provides.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1836 ;; This mechanism is used so that the ada-mode can "explain" how the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1837 ;; indentation was calculated, by showing which variables were used.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1838 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1839 ;; The indentation itself is done in only one pass: first we try to guess in
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1840 ;; what context we are by looking at the following keyword or punctuation
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1841 ;; sign. If nothing remarkable is found, just try to guess the indentation
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1842 ;; based on previous lines.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1843 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1844 ;; The relevant functions for indentation are:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1845 ;; - `ada-indent-region': Re-indent a region of text
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1846 ;; - `ada-justified-indent-current': Re-indent the current line and shows the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1847 ;; calculation that were done
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1848 ;; - `ada-indent-current': Re-indent the current line
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1849 ;; - `ada-get-current-indent': Calculate the indentation for the current line,
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1850 ;; based on the context (see above).
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1851 ;; - `ada-get-indent-*': Calculate the indentation in a specific context.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1852 ;; For efficiency, these functions do not check they are in the correct
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1853 ;; context.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1854 ;;;----------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1855
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856 (defun ada-indent-region (beg end)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1857 "Indent the region between BEG end END."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1858 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859 (goto-char beg)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1860 (let ((block-done 0)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1861 (lines-remaining (count-lines beg end))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1862 (msg (format "%%4d out of %4d lines remaining ..."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1863 (count-lines beg end)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1864 (endmark (copy-marker end)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1865 ;; catch errors while indenting
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1866 (while (< (point) endmark)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1867 (if (> block-done 39)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1868 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1869 (setq lines-remaining (- lines-remaining block-done)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1870 block-done 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1871 (message msg lines-remaining)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1872 (if (= (char-after) ?\n) nil
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1873 (ada-indent-current))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1874 (forward-line 1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1875 (setq block-done (1+ block-done)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1876 (message "indenting ... done")))
10705
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 (defun ada-indent-newline-indent ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1879 "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
1880 (interactive "*")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1881 (ada-indent-current)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1882 (newline)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1883 (ada-indent-current))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1885 (defun ada-indent-newline-indent-conditional ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1886 "Insert a newline and indent it.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1887 The original line is indented first if `ada-indent-after-return' is non-nil.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1888 This function is intended to be bound to the \C-m and \C-j keys."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1889 (interactive "*")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1890 (if ada-indent-after-return (ada-indent-current))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1891 (newline)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1892 (ada-indent-current))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1893
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1894 (defun ada-justified-indent-current ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1895 "Indent the current line and explains how the calculation was done."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1896 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1897
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1898 (let ((cur-indent (ada-indent-current)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1899
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1900 (message nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1901 (if (equal (cdr cur-indent) '(0))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1902 (message "same indentation")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1903 (message (mapconcat (lambda(x)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1904 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1905 ((symbolp x)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1906 (symbol-name x))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1907 ((numberp x)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1908 (number-to-string x))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1909 ((listp x)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1910 (concat "- " (symbol-name (cadr x))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1911 ))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1912 (cdr cur-indent)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1913 " + ")))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1914 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1915 (goto-char (car cur-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1916 (sit-for 1))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1918 (defun ada-batch-reformat ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1919 "Re-indent and re-case all the files found on the command line.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1920 This function should be used from the Unix/Windows command line, with a
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1921 command like:
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1922 emacs -batch -l ada-mode -f ada-batch-reformat file1 file2 ..."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1923
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1924 (while command-line-args-left
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1925 (let ((source (car command-line-args-left)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1926 (message (concat "formating " source))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1927 (find-file source)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1928 (ada-indent-region (point-min) (point-max))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1929 (ada-adjust-case-buffer)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1930 (write-file source))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1931 (set 'command-line-args-left (cdr command-line-args-left)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1932 (message "Done")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1933 (kill-emacs 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1934
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1935 (defsubst ada-goto-previous-word ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1936 "Moves point to the beginning of the previous word of Ada code.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1937 Returns the new position of point or nil if not found."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1938 (ada-goto-next-word t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1939
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 (defun ada-indent-current ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1941 "Indent current line as Ada code.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1942 Returns the calculation that was done, including the reference point and the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1943 offset."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1945 (let ((previous-syntax-table (syntax-table))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1946 (orgpoint (point-marker))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1947 cur-indent tmp-indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1948 prev-indent)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1949
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1950 (unwind-protect
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1951 (progn
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1952 (set-syntax-table ada-mode-symbol-syntax-table)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1953
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1954 ;; This need to be done here so that the advice is not always
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1955 ;; activated (this might interact badly with other modes)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1956 (if ada-xemacs
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1957 (ad-activate 'parse-partial-sexp t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1958
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1959 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1960 (set 'cur-indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1961
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1962 ;; Not First line in the buffer ?
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1963 (if (save-excursion (zerop (forward-line -1)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1964 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1965 (back-to-indentation)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1966 (ada-get-current-indent))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1967
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1968 ;; first line in the buffer
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1969 (list (point-min) 0))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1970
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1971 ;; Evaluate the list to get the column to indent to
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1972 ;; prev-indent contains the column to indent to
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1973 (if cur-indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1974 (setq prev-indent (save-excursion (goto-char (car cur-indent))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1975 (current-column))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1976 tmp-indent (cdr cur-indent))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1977 (setq prev-indent 0 tmp-indent '()))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1978
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1979 (while (not (null tmp-indent))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1980 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1981 ((numberp (car tmp-indent))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1982 (set 'prev-indent (+ prev-indent (car tmp-indent))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1983 (t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1984 (set 'prev-indent (+ prev-indent (eval (car tmp-indent)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1985 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1986 (set 'tmp-indent (cdr tmp-indent)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1987
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1988 ;; only re-indent if indentation is different then the current
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1989 (if (= (save-excursion (back-to-indentation) (current-column)) prev-indent)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1990 nil
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1991 (beginning-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1992 (delete-horizontal-space)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1993 (indent-to prev-indent))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1994 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1995 ;; restore position of point
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1996 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1997 (goto-char orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1998 (if (< (current-column) (current-indentation))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
1999 (back-to-indentation)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2000
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2001 ;; restore syntax-table
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2002 (set-syntax-table previous-syntax-table)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2003 (if ada-xemacs
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2004 (ad-deactivate 'parse-partial-sexp))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2005 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2006
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2007 cur-indent
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2008 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2009
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2010 (defun ada-get-current-indent ()
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2011 "Return the indentation to use for the current line."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2012 (let (column
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2013 pos
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2014 match-cons
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2015 result
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2016 (orgpoint (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2017 (beginning-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2018 (forward-comment -10000)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2019 (forward-line 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2020 (point))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2021
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2022 (set 'result
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023 (cond
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2024
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2025 ;;-----------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2026 ;; in open parenthesis, but not in parameter-list
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2027 ;;-----------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2028
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2029 ((and ada-indent-to-open-paren
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2030 (not (ada-in-paramlist-p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2031 (set 'column (ada-in-open-paren-p)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2032
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 ;; check if we have something like this (Table_Component_Type =>
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2034 ;; Source_File_Record)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2036 (if (and (skip-chars-backward " \t")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2037 (= (char-before) ?\n)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2038 (not (forward-comment -10000))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2039 (= (char-before) ?>))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2040 ;; ??? Could use a different variable
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2041 (list column 'ada-broken-indent)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2042 (list column 0))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2043
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2044 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2045 ;; at end of buffer
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2046 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2047
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2048 ((not (char-after))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2049 (ada-indent-on-previous-lines nil orgpoint orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2050
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2051 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2052 ;; starting with e
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2053 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2054
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2055 ((= (char-after) ?e)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2056 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2057
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2058 ;; ------- end ------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2059
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2060 ((looking-at "end\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2061 (let ((label 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2062 limit)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2063 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2064 (ada-goto-matching-start 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2065
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2066 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2067 ;; found 'loop' => skip back to 'while' or 'for'
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2068 ;; if 'loop' is not on a separate line
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2069 ;; Stop the search for 'while' and 'for' when a ';' is encountered.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2070 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2071 (if (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2072 (beginning-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2073 (looking-at ".+\\<loop\\>"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2074 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2075 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2076 (set 'limit (car (ada-search-ignore-string-comment ";" t))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2077 (if (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2078 (and
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2079 (set 'match-cons
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2080 (ada-search-ignore-string-comment ada-loop-start-re t limit))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2081 (not (looking-at "\\<loop\\>"))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2082 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2083 (goto-char (car match-cons))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2084 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2085 (beginning-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2086 (if (looking-at ada-named-block-re)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2087 (set 'label (- ada-label-indent))))))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2088
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2089 (list (+ (save-excursion (back-to-indentation) (point)) label) 0))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2090
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2091 ;; ------ exception ----
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2092
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2093 ((looking-at "exception\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2094 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2095 (ada-goto-matching-start 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2096 (list (save-excursion (back-to-indentation) (point)) 0)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2097
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2098 ;; else
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2099
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2100 ((looking-at "else\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2101 (if (save-excursion (ada-goto-previous-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2102 (looking-at "\\<or\\>"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2103 (ada-indent-on-previous-lines nil orgpoint orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2104 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2105 (ada-goto-matching-start 1 nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2106 (list (progn (back-to-indentation) (point)) 0))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2107
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2108 ;; elsif
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2109
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2110 ((looking-at "elsif\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2111 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2112 (ada-goto-matching-start 1 nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2113 (list (progn (back-to-indentation) (point)) 0)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2114
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2115 ))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2116
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2117 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2118 ;; starting with w (when)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2119 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2120
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2121 ((and (= (char-after) ?w)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2122 (looking-at "when\\>"))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 (save-excursion
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2124 (ada-goto-matching-start 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2125 (list (save-excursion (back-to-indentation) (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2126 'ada-when-indent)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2127
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2128 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2129 ;; starting with t (then)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2130 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2131
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2132 ((and (= (char-after) ?t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2133 (looking-at "then\\>"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2134 (if (save-excursion (ada-goto-previous-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2135 (looking-at "and\\>"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2136 (ada-indent-on-previous-lines nil orgpoint orgpoint)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2137 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2138 ;; Select has been added for the statement: "select ... then abort"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2139 (ada-search-ignore-string-comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2140 "\\<\\(elsif\\|if\\|select\\)\\>" t nil)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2141 (list (progn (back-to-indentation) (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2142 'ada-stmt-end-indent))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2143
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2144 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2145 ;; starting with l (loop)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2146 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2147
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2148 ((and (= (char-after) ?l)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2149 (looking-at "loop\\>"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2150 (set 'pos (point))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 (ada-goto-stmt-start)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2154 (if (looking-at "\\<\\(loop\\|if\\)\\>")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2155 (ada-indent-on-previous-lines nil orgpoint orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2156 (unless (looking-at ada-loop-start-re)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2157 (ada-search-ignore-string-comment ada-loop-start-re
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2158 nil pos))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2159 (if (looking-at "\\<loop\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2160 (ada-indent-on-previous-lines nil orgpoint orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2161 (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2162
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2163 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2164 ;; starting with b (begin)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2165 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2166
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2167 ((and (= (char-after) ?b)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2168 (looking-at "begin\\>"))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2169 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2170 (if (ada-goto-matching-decl-start t)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2171 (list (progn (back-to-indentation) (point)) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2172 (ada-indent-on-previous-lines nil orgpoint orgpoint))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2173
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2174 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2175 ;; starting with i (is)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2176 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2177
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2178 ((and (= (char-after) ?i)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2179 (looking-at "is\\>"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2180
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2181 (if (and ada-indent-is-separate
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2182 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2183 (goto-char (match-end 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2184 (ada-goto-next-non-ws (save-excursion (end-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2185 (point)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2186 (looking-at "\\<abstract\\>\\|\\<separate\\>")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2188 (ada-goto-stmt-start)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2189 (list (progn (back-to-indentation) (point)) 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 (ada-goto-stmt-start)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2192 (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2193
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2194 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2195 ;; starting with r (record, return, renames)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2196 ;;---------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2197
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2198 ((= (char-after) ?r)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2199
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2200 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2201
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2202 ;; ----- record ------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2203
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2204 ((looking-at "record\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2205 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2206 (ada-search-ignore-string-comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2207 "\\<\\(type\\|use\\)\\>" t nil)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2208 (if (looking-at "\\<use\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2209 (ada-search-ignore-string-comment "for" t nil nil 'word-search-backward))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2210 (list (progn (back-to-indentation) (point)) 'ada-indent-record-rel-type)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2211
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2212 ;; ----- return or renames ------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2213
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2214 ((looking-at "re\\(turn\\|names\\)\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2215 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2216 (let ((var 'ada-indent-return))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2217 ;; If looking at a renames, skip the 'return' statement too
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2218 (if (looking-at "renames")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2219 (let (pos)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2220 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2221 (set 'pos (ada-search-ignore-string-comment ";\\|return\\>" t)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2222 (if (and pos
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2223 (= (char-after (car pos)) ?r))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2224 (goto-char (car pos)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2225 (set 'var 'ada-indent-renames)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2226
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2227 (forward-comment -1000)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2228 (if (= (char-before) ?\))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2229 (forward-sexp -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2230 (forward-word -1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2231
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2232 ;; If there is a parameter list, and we have a function declaration
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2233 ;; or a access to subprogram declaration
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2234 (let ((num-back 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2235 (if (and (= (char-after) ?\()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2236 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2237 (or (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2238 (backward-word 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2239 (looking-at "function\\>"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2240 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2241 (backward-word 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2242 (set 'num-back 2)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2243 (looking-at "function\\>")))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2244
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2245 ;; The indentation depends of the value of ada-indent-return
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2246 (if (<= (eval var) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2247 (list (point) (list '- var))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2248 (list (progn (backward-word num-back) (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2249 var))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2250
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2251 ;; Else there is no parameter list, but we have a function
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2252 ;; Only do something special if the user want to indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2253 ;; relative to the "function" keyword
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2254 (if (and (> (eval var) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2255 (save-excursion (forward-word -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2256 (looking-at "function\\>")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2257 (list (progn (forward-word -1) (point)) var)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2258
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2259 ;; Else...
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2260 (ada-indent-on-previous-lines nil orgpoint orgpoint)))))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2261 ))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2262
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2263 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2264 ;; starting with 'o' or 'p'
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2265 ;; 'or' as statement-start
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2266 ;; 'private' as statement-start
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2267 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2268
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2269 ((and (or (= (char-after) ?o)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2270 (= (char-after) ?p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2271 (or (ada-looking-at-semi-or)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2272 (ada-looking-at-semi-private)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 (ada-goto-matching-start 1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2275 (list (progn (back-to-indentation) (point)) 0)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2276
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2277 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2278 ;; starting with 'd' (do)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2279 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2280
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2281 ((and (= (char-after) ?d)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2282 (looking-at "do\\>"))
10705
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 (ada-goto-stmt-start)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2285 (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2286
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2287 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2288 ;; starting with '-' (comment)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2289 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2290
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2291 ((= (char-after) ?-)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2292 (if ada-indent-comment-as-code
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2293
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2294 ;; Indent comments on previous line comments if required
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2295 ;; We must use a search-forward (even if the code is more complex),
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2296 ;; since we want to find the beginning of the comment.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2297 (let (pos)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2298
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2299 (if (and ada-indent-align-comments
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2300 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2301 (forward-line -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2302 (beginning-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2303 (while (and (not pos)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2304 (search-forward "--"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2305 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2306 (end-of-line) (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2307 t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2308 (unless (ada-in-string-p)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2309 (set 'pos (point))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2310 pos))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2311 (list (- pos 2) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2312
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2313 ;; Else always on previous line
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2314 (ada-indent-on-previous-lines nil orgpoint orgpoint)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2315
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2316 ;; Else same indentation as the previous line
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2317 (list (save-excursion (back-to-indentation) (point)) 0)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2318
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2319 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2320 ;; starting with '#' (preprocessor line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2321 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2322
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2323 ((and (= (char-after) ?#)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2324 (equal ada-which-compiler 'gnat)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2325 (looking-at "#[ \t]*\\(if\\|els\\(e\\|if\\)\\|end[ \t]*if\\)"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2326 (list (save-excursion (beginning-of-line) (point)) 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2327
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2328 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2329 ;; starting with ')' (end of a parameter list)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2330 ;;--------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2331
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2332 ((and (not (eobp)) (= (char-after) ?\)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2333 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2335 (backward-sexp 1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2336 (list (point) 0)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2337
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2338 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2339 ;; new/abstract/separate
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2340 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2341
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2342 ((looking-at "\\(new\\|abstract\\|separate\\)\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2343 (ada-indent-on-previous-lines nil orgpoint orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2344
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2345 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2346 ;; package/function/procedure
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2347 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2348
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2349 ((and (or (= (char-after) ?p) (= (char-after) ?f))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2350 (looking-at "\\<\\(package\\|function\\|procedure\\)\\>"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2351 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2352 ;; Go up until we find either a generic section, or the end of the
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2353 ;; previous subprogram/package
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2354 (let (found)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2355 (while (and (not found)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2356 (ada-search-ignore-string-comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2357 "\\<\\(generic\\|end\\|begin\\|package\\|procedure\\|function\\)\\>" t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2358
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2359 ;; avoid "with procedure"... in generic parts
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2360 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2361 (forward-word -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2362 (set 'found (not (looking-at "with"))))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2363
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2364 (if (looking-at "generic")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2365 (list (progn (back-to-indentation) (point)) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2366 (ada-indent-on-previous-lines nil orgpoint orgpoint))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2367
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2368 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2369 ;; label
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2370 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2371
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2372 ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2373 (if (ada-in-decl-p)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2374 (ada-indent-on-previous-lines nil orgpoint orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2375 (append (ada-indent-on-previous-lines nil orgpoint orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2376 '(ada-label-indent))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2377
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2378 ))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2379
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2380 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2381 ;; Other syntaxes
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2382 ;;---------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2383 (or result (ada-indent-on-previous-lines nil orgpoint orgpoint))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2384
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2385 (defun ada-indent-on-previous-lines (&optional nomove orgpoint initial-pos)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2386 "Calculate the indentation for the new line after ORGPOINT.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2387 The result list is based on the previous lines in the buffer.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2388 If NOMOVE is nil, moves point to the beginning of the current statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2389 if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2390 (if initial-pos
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2391 (goto-char initial-pos))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2392 (let ((oldpoint (point)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2393
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2394 ;; Is inside a parameter-list ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2395 (if (ada-in-paramlist-p)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2396 (ada-get-indent-paramlist)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2397
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2398 ;; move to beginning of current statement
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2399 (unless nomove
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2400 (ada-goto-stmt-start))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2401
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2402 ;; no beginning found => don't change indentation
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2403 (if (and (eq oldpoint (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2404 (not nomove))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2405 (ada-get-indent-nochange)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2406
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2407 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2408 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2409 ((and
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2410 ada-indent-to-open-paren
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2411 (ada-in-open-paren-p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2412 (ada-get-indent-open-paren))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2413 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2414 ((looking-at "end\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2415 (ada-get-indent-end orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2416 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2417 ((looking-at ada-loop-start-re)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2418 (ada-get-indent-loop orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2419 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2420 ((looking-at ada-subprog-start-re)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2421 (ada-get-indent-subprog orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2422 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2423 ((looking-at ada-block-start-re)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2424 (ada-get-indent-block-start orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2425 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2426 ((looking-at "\\(sub\\)?type\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2427 (ada-get-indent-type orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2428 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2429 ;; "then" has to be included in the case of "select...then abort"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2430 ;; statements, since (goto-stmt-start) at the beginning of
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2431 ;; the current function would leave the cursor on that position
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2432 ((looking-at "\\(\\(els\\)?if\\>\\)\\|then abort\\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2433 (ada-get-indent-if orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2434 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2435 ((looking-at "case\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2436 (ada-get-indent-case orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2437 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2438 ((looking-at "when\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2439 (ada-get-indent-when orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2440 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2441 ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2442 (ada-get-indent-label orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2443 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2444 ((looking-at "separate\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2445 (ada-get-indent-nochange))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2446 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2447 ((looking-at "with\\>\\|use\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2448 ;; Are we still in that statement, or are we in fact looking at
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2449 ;; the previous one ?
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2450 (if (save-excursion (search-forward ";" oldpoint t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2451 (list (progn (back-to-indentation) (point)) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2452 (list (point) (if (looking-at "with")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2453 'ada-with-indent
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2454 'ada-use-indent))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2455 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2456 (t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2457 (ada-get-indent-noindent orgpoint)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2458 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2460 (defun ada-get-indent-open-paren ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2461 "Calculates the indentation when point is behind an unclosed parenthesis."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2462 (list (ada-in-open-paren-p) 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2464 (defun ada-get-indent-nochange ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2465 "Return the current indentation of the previous line."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 (forward-line -1)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2468 (back-to-indentation)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2469 (list (point) 0)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2470
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2471 (defun ada-get-indent-paramlist ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2472 "Calculates the indentation when point is inside a parameter list."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474 (ada-search-ignore-string-comment "[^ \t\n]" t nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 ;; in front of the first parameter
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2477 ((= (char-after) ?\()
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478 (goto-char (match-end 0))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2479 (list (point) 0))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2480
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 ;; in front of another parameter
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2482 ((= (char-after) ?\;)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2485 (list (point) 0))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2486
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487 ;; inside a parameter declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2491 (list (point) 'ada-broken-indent)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2492
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2493 (defun ada-get-indent-end (orgpoint)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2494 "Calculates the indentation when point is just before an end_statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2495 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 (let ((defun-name nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497 (indent nil))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2498
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 ;; is the line already terminated by ';' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 (if (save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2501 (ada-search-ignore-string-comment ";" nil orgpoint nil
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2502 'search-forward))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2503
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 ;; yes, look what's following 'end'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 (cond
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2509 ((looking-at "\\<\\(loop\\|select\\|if\\|case\\)\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2510 (save-excursion (ada-check-matching-start (match-string 0)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2511 (list (save-excursion (back-to-indentation) (point)) 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2512
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 ;; loop/select/if/case/record/select
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2516 ((looking-at "\\<record\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2518 (ada-check-matching-start (match-string 0))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2519 ;; we are now looking at the matching "record" statement
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2520 (forward-word 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2521 (ada-goto-stmt-start)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2522 ;; now on the matching type declaration, or use clause
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2523 (unless (looking-at "\\(for\\|type\\)\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2524 (ada-search-ignore-string-comment "\\<type\\>" t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2525 (list (progn (back-to-indentation) (point)) 0)))
10705
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 ;; a named block end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2529 ((looking-at ada-ident-re)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2530 (set 'defun-name (match-string 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2531 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2532 (ada-goto-matching-start 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2533 (ada-check-defun-name defun-name))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2534 (list (progn (back-to-indentation) (point)) 0))
10705
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 ;; a block-end without name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2538 ((= (char-after) ?\;)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2539 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2540 (ada-goto-matching-start 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2541 (if (looking-at "\\<begin\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2542 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2543 (set 'indent (list (point) 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2544 (if (ada-goto-matching-decl-start t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2545 (list (progn (back-to-indentation) (point)) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2546 indent)))))
10705
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 ;; anything else - should maybe signal an error ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 (t
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2551 (list (save-excursion (back-to-indentation) (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2552 'ada-broken-indent))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2553
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2554 (list (save-excursion (back-to-indentation) (point))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2555 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2556
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557 (defun ada-get-indent-case (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2558 "Calculates the indentation when point is just before a case statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2559 ORGPOINT is the limit position used in the calculation."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2560 (let ((match-cons nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 (opos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2563 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564 ;; case..is..when..=>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2567 (set 'match-cons (and
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2568 ;; the `=>' must be after the keyword `is'.
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2569 (ada-search-ignore-string-comment
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2570 "is" nil orgpoint nil 'word-search-forward)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2571 (ada-search-ignore-string-comment
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2572 "[ \t\n]+=>" nil orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2573 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 (goto-char (car match-cons))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2575 (unless (ada-search-ignore-string-comment "when" t opos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2576 (error "missing 'when' between 'case' and '=>'"))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2577 (list (save-excursion (back-to-indentation) (point)) 'ada-indent)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 ;; case..is..when
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2582 (set 'match-cons (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2583 "when" nil orgpoint nil 'word-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 (goto-char (cdr match-cons))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2585 (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 ;; case..is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2590 (set 'match-cons (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2591 "is" nil orgpoint nil 'word-search-forward)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2592 (list (save-excursion (back-to-indentation) (point)) 'ada-when-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 ;; incomplete case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596 (t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2597 (list (save-excursion (back-to-indentation) (point))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2598 'ada-broken-indent)))))
10705
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 (defun ada-get-indent-when (orgpoint)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2601 "Calculates the indentation when point is just before a when statement.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2602 ORGPOINT is the limit position used in the calculation."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2603 (let ((cur-indent (save-excursion (back-to-indentation) (point))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2604 (if (ada-search-ignore-string-comment "[ \t\n]*=>" nil orgpoint)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2605 (list cur-indent 'ada-indent)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2606 (list cur-indent 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 (defun ada-get-indent-if (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2609 "Calculates the indentation when point is just before an if statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2610 ORGPOINT is the limit position used in the calculation."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2611 (let ((cur-indent (save-excursion (back-to-indentation) (point)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2614 ;; Move to the correct then (ignore all "and then")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2616 (while (and (set 'match-cons (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2617 "\\<\\(then\\|and[ \t]*then\\)\\>"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2618 nil orgpoint))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2619 (= (char-after (car match-cons)) ?a)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2620 ;; If "then" was found (we are looking at it)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2621 (if match-cons
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2622 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 ;; 'then' first in separate line ?
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2625 ;; => indent according to 'then',
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2626 ;; => else indent according to 'if'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2627 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2628 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2629 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630 (looking-at "\\<then\\>"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2631 (set 'cur-indent (save-excursion (back-to-indentation) (point))))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2632 ;; skip 'then'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (forward-word 1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2634 (list cur-indent 'ada-indent))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2635
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2636 (list cur-indent 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 (defun ada-get-indent-block-start (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2639 "Calculates the indentation when point is at the start of a block.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2640 ORGPOINT is the limit position used in the calculation."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2641 (let ((pos nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2642 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2644 (forward-word 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2645 (set 'pos (ada-goto-next-non-ws orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 (goto-char pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2648 (ada-indent-on-previous-lines t orgpoint)))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2649
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 ;; nothing follows the block-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2652 (list (save-excursion (back-to-indentation) (point)) 'ada-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 (defun ada-get-indent-subprog (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2655 "Calculates the indentation when point is just before a subprogram.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2656 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (let ((match-cons nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2658 (cur-indent (save-excursion (back-to-indentation) (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2659 (foundis nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2661 ;; is there an 'is' in front of point ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2662 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (if (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2664 (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2665 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2666 "\\<\\(is\\|do\\)\\>" nil orgpoint)))
10705
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 ;; yes, then skip to its end
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 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2671 (set 'foundis t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2672 (goto-char (cdr match-cons)))
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 ;; 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
2675 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2676 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2677 (unless (ada-goto-next-non-ws orgpoint)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678 (goto-char orgpoint))))
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 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2681 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2682 ;; nothing follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2683 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2684 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2685 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2686 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2687 (not (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2688 "[^ \t\n]" nil orgpoint t))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2689 (list cur-indent 'ada-indent))
10705
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 ;; is abstract/separate/new ...
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2693 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2694 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2696 (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2697 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2698 "\\<\\(separate\\|new\\|abstract\\)\\>"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2699 nil orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700 (goto-char (car match-cons))
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
2701 (ada-search-ignore-string-comment ada-subprog-start-re t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2702 (ada-get-indent-noindent orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2703 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 ;; something follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2705 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2706 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2707 foundis
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2708 (save-excursion (set 'match-cons (ada-goto-next-non-ws orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2709 (goto-char match-cons)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2710 (ada-indent-on-previous-lines t orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2711 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2712 ;; no 'is' but ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2713 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2714 ((save-excursion
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2715 (ada-search-ignore-string-comment ";" nil orgpoint nil 'search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2716 (list cur-indent 0))
10705
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 ;; no 'is' or ';'
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 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2721 (list cur-indent 'ada-broken-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2722
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2723 (defun ada-get-indent-noindent (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2724 "Calculates the indentation when point is just before a 'noindent stmt'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2725 ORGPOINT is the limit position used in the calculation."
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2726 (let ((label 0))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2727 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2728 (beginning-of-line)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2729
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2730 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2731
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2732 ;; This one is called when indenting a line preceded by a multi-line
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2733 ;; subprogram declaration (in that case, we are at this point inside
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2734 ;; the parameter declaration list)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2735 ((ada-in-paramlist-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2736 (ada-previous-procedure)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2737 (list (save-excursion (back-to-indentation) (point)) 0))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2738
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2739 ;; This one is called when indenting the second line of a multi-line
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2740 ;; declaration section, in a declare block or a record declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2741 ((looking-at "[ \t]*\\(\\sw\\|_\\)*[ \t]*,[ \t]*$")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2742 (list (save-excursion (back-to-indentation) (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2743 'ada-broken-decl-indent))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2744
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2745 ;; This one is called in every over case when indenting a line at the
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2746 ;; top level
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2747 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2748 (if (looking-at ada-named-block-re)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2749 (set 'label (- ada-label-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2750
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2751 (let (p)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2752
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2753 ;; "with private" or "null record" cases
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2754 (if (or (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2755 (and (ada-search-ignore-string-comment "\\<private\\>" nil orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2756 (set 'p (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2757 (save-excursion (forward-char -7);; skip back "private"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2758 (ada-goto-previous-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2759 (looking-at "with"))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2760 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2761 (and (ada-search-ignore-string-comment "\\<record\\>" nil orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2762 (set 'p (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2763 (save-excursion (forward-char -6);; skip back "record"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2764 (ada-goto-previous-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2765 (looking-at "null")))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2766 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2767 (goto-char p)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2768 (re-search-backward "\\<\\(type\\|subtype\\)\\>" nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2769 (list (save-excursion (back-to-indentation) (point)) 0)))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2770 (if (save-excursion
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2771 (ada-search-ignore-string-comment ";" nil orgpoint nil
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2772 'search-forward))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2773 (list (+ (save-excursion (back-to-indentation) (point)) label) 0)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2774 (list (+ (save-excursion (back-to-indentation) (point)) label)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2775 'ada-broken-indent)))))))
10705
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 (defun ada-get-indent-label (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2778 "Calculates the indentation when before a label or variable declaration.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2779 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 (let ((match-cons nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2781 (cur-indent (save-excursion (back-to-indentation) (point))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2782 (ada-search-ignore-string-comment ":" nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2784 ;; loop label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2785 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2786 (set 'match-cons (ada-search-ignore-string-comment
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2787 ada-loop-start-re nil orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2788 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2789 (ada-get-indent-loop orgpoint))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2790
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791 ;; declare label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2793 (set 'match-cons (ada-search-ignore-string-comment
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2794 "\\<declare\\|begin\\>" nil orgpoint)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2795 (goto-char (car match-cons))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2796 (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2797
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2798 ;; variable declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2799 ((ada-in-decl-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2800 (if (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2801 (ada-search-ignore-string-comment ";" nil orgpoint))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2802 (list cur-indent 0)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2803 (list cur-indent 'ada-broken-indent)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2804
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2805 ;; nothing follows colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2806 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2807 (list cur-indent '(- ada-label-indent))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2808
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2809 (defun ada-get-indent-loop (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2810 "Calculates the indentation when just before a loop or a for ... use.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2811 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2812 (let ((match-cons nil)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2813 (pos (point))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2814
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2815 ;; If looking at a named block, skip the label
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2816 (label (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2817 (beginning-of-line)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2818 (if (looking-at ada-named-block-re)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2819 (- ada-label-indent)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2820 0))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2821
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2822 (cond
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 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2825 ;; statement complete
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2826 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2827 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2828 (ada-search-ignore-string-comment ";" nil orgpoint nil
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2829 'search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2830 (list (+ (save-excursion (back-to-indentation) (point)) label) 0))
10705
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 ;; simple loop
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 ((looking-at "loop\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2835 (set 'pos (ada-get-indent-block-start orgpoint))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2836 (if (equal label 0)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2837 pos
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2838 (list (+ (car pos) label) (cdr pos))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839
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 ;; 'for'- loop (or also a for ... use statement)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843 ((looking-at "for\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 ;; for ... use
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2848 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2849 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2850 (goto-char (match-end 0))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2851 (ada-goto-next-non-ws orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2852 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2853 (if (= (char-after) ?') (forward-word 1) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2854 (ada-goto-next-non-ws orgpoint)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855 (looking-at "\\<use\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 ;; check if there is a 'record' before point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2860 (set 'match-cons (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2861 "record" nil orgpoint nil 'word-search-forward))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 (if match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864 (goto-char (car match-cons)))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2865 (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 ;; for..loop
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 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2870 (set 'match-cons (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2871 "loop" nil orgpoint nil 'word-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2872 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2873 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2874 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2875 ;; otherwise to 'for'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2876 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2877 (unless (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2878 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2879 (looking-at "\\<loop\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2880 (goto-char pos))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2881 (list (+ (save-excursion (back-to-indentation) (point)) label)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2882 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 ;; for-statement is broken
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 (t
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2887 (list (+ (save-excursion (back-to-indentation) (point)) label)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2888 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891 ;; 'while'-loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893 ((looking-at "while\\>")
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 ;; while..loop ?
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 (if (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2898 (set 'match-cons (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2899 "loop" nil orgpoint nil 'word-search-forward)))
10705
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 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2904 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 ;; otherwise to 'while'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2907 (unless (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2908 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2909 (looking-at "\\<loop\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2910 (goto-char pos))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2911 (list (+ (save-excursion (back-to-indentation) (point)) label)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2912 'ada-indent))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2913
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2914 (list (+ (save-excursion (back-to-indentation) (point)) label)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2915 'ada-broken-indent))))))
10705
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 (defun ada-get-indent-type (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2918 "Calculates the indentation when before a type statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2919 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 (let ((match-dat nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921 (cond
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 ;; complete record declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2924 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926 (and
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2927 (set 'match-dat (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2928 "end" nil orgpoint nil 'word-search-forward))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930 (looking-at "\\<record\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2933 (= (char-after) ?\;)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 (goto-char (car match-dat))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2935 (list (save-excursion (back-to-indentation) (point)) 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 ;; record type
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 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2940 (set 'match-dat (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2941 "record" nil orgpoint nil 'word-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2942 (goto-char (car match-dat))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2943 (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2944 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2945 ;; complete type declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2948 (ada-search-ignore-string-comment ";" nil orgpoint nil
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2949 'search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2950 (list (save-excursion (back-to-indentation) (point)) 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2952 ;; "type ... is", but not "type ... is ...", which is broken
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2955 (and
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2956 (ada-search-ignore-string-comment "is" nil orgpoint nil
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2957 'word-search-forward)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2958 (not (ada-goto-next-non-ws orgpoint))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2959 (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 ;; broken statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 (t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2964 (list (save-excursion (back-to-indentation) (point))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2965 'ada-broken-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2966
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2967
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2968 ;; -----------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2969 ;; -- searching and matching
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2970 ;; -----------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2971
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2972 (defun ada-goto-stmt-start ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2973 "Moves point to the beginning of the statement that point is in or after.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2974 Returns the new position of point.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2975 As a special case, if we are looking at a closing parenthesis, skip to the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2976 open parenthesis."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 (let ((match-dat nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 (orgpoint (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2980 (set 'match-dat (ada-search-prev-end-stmt))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981 (if match-dat
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2982
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2983 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2984 ;; found a previous end-statement => check if anything follows
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2985 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2986 (unless (looking-at "declare")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2987 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2988 (unless (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2989 (goto-char (cdr match-dat))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2990 (ada-goto-next-non-ws orgpoint))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2991 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2992 ;; nothing follows => it's the end-statement directly in
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2993 ;; front of point => search again
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2994 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2995 (set 'match-dat (ada-search-prev-end-stmt)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2996 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2997 ;; if found the correct end-statement => goto next non-ws
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2998 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
2999 (if match-dat
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3000 (goto-char (cdr match-dat)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3001 (ada-goto-next-non-ws)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3002 ))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3003
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3004 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3005 ;; no previous end-statement => we are at the beginning of the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3006 ;; accessible part of the buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3007 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3008 (progn
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3009 (goto-char (point-min))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3010 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3011 ;; skip to the very first statement, if there is one
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3012 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3013 (unless (ada-goto-next-non-ws orgpoint)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3014 (goto-char orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3015 (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3017
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3018 (defun ada-search-prev-end-stmt ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3019 "Moves point to previous end-statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3020 Returns a cons cell whose car is the beginning and whose cdr the end of the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3021 match."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022 (let ((match-dat nil)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3023 (found nil))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3024
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3025 ;; search until found or beginning-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026 (while
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3027 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3028 (not found)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3029 (set 'match-dat (ada-search-ignore-string-comment
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3030 ada-end-stmt-re t)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3031
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3032 (goto-char (car match-dat))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3033 (unless (ada-in-open-paren-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3034 (if (and (looking-at
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3035 "\\<\\(record\\|loop\\|select\\|else\\|then\\)\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3036 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3037 (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3038 (looking-at "\\<\\(end\\|or\\|and\\)\\>[ \t]*[^;]")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3039 (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3040
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3041 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3042 (goto-char (cdr match-dat))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3043 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3044 (looking-at "(")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3045 ;; words that can go after an 'is'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3046 (unless (looking-at
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3047 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3048 (concat "\\<"
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3049 (regexp-opt '("separate" "access" "array"
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3050 "abstract" "new") t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3051 "\\>\\|(")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3052 (set 'found t))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3053 ))
10705
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 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056 match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 (defun ada-goto-next-non-ws (&optional limit)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3061 "Skips white spaces, newlines and comments to next non-ws character.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3062 Stop the search at LIMIT.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3063 Do not call this function from within a string."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3064 (unless limit
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3065 (set 'limit (point-max)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3066 (while (and (<= (point) limit)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3067 (progn (forward-comment 10000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3068 (if (and (not (eobp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3069 (save-excursion (forward-char 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3070 (ada-in-string-p)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3071 (progn (forward-sexp 1) t)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3072 (if (< (point) limit)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3073 (point)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3074 nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3075 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3076
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3077
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3078 (defun ada-goto-stmt-end (&optional limit)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3079 "Moves point to the end of the statement that point is in or before.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3080 Returns the new position of point or nil if not found.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3081 Stop the search at LIMIT."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3082 (if (ada-search-ignore-string-comment ada-end-stmt-re nil limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3083 (point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3084 nil))
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
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3087 (defun ada-goto-next-word (&optional backward)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3088 "Moves point to the beginning of the next word of Ada code.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3089 If BACKWARD is non-nil, jump to the beginning of the previous word.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3090 Returns the new position of point or nil if not found."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3091 (let ((match-cons nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3092 (orgpoint (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3093 (old-syntax (char-to-string (char-syntax ?_))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3094 (modify-syntax-entry ?_ "w")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3095 (unless backward
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3096 (skip-syntax-forward "w"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3097 (if (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3098 (if backward
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3099 (ada-search-ignore-string-comment "\\w" t nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3100 (ada-search-ignore-string-comment "\\w" nil nil t)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3101 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3102 ;; move to the beginning of the word found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3103 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3104 (progn
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3105 (goto-char (car match-cons))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3106 (skip-syntax-backward "w")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3107 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 ;; if not found, restore old position of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3110 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3111 (goto-char orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3112 'nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3113 (modify-syntax-entry ?_ old-syntax))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3114 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3115
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3116
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 (defun ada-check-matching-start (keyword)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3118 "Signals an error if matching block start is not KEYWORD.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3119 Moves point to the matching block start."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3120 (ada-goto-matching-start 0)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3121 (unless (looking-at (concat "\\<" keyword "\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3122 (error "matching start is not '%s'" keyword)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3123
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3124
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125 (defun ada-check-defun-name (defun-name)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3126 "Checks if the name of the matching defun really is DEFUN-NAME.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3127 Assumes point to be already positioned by 'ada-goto-matching-start'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3128 Moves point to the beginning of the declaration."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3129
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3130 ;; named block without a `declare'
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3131 (if (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3132 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3133 (looking-at (concat "\\<" defun-name "\\> *:")))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3134 t ; do nothing
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3135 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3136 ;; 'accept' or 'package' ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3137 ;;
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3138 (unless (looking-at ada-subprog-start-re)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3139 (ada-goto-matching-decl-start))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3140 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3141 ;; 'begin' of 'procedure'/'function'/'task' or 'declare'
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3142 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3143 (save-excursion
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3144 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3145 ;; a named 'declare'-block ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3146 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3147 (if (looking-at "\\<declare\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3148 (ada-goto-stmt-start)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3149 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3150 ;; no, => 'procedure'/'function'/'task'/'protected'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3152 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3153 (forward-word 2)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3154 (backward-word 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3155 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3156 ;; skip 'body' 'type'
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3157 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3158 (if (looking-at "\\<\\(body\\|type\\)\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3159 (forward-word 1))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3160 (forward-sexp 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3161 (backward-sexp 1)))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3162 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3163 ;; should be looking-at the correct name
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3164 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3165 (unless (looking-at (concat "\\<" defun-name "\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3166 (error "matching defun has different name: %s"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3167 (buffer-substring (point)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3168 (progn (forward-sexp 1) (point))))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3170 (defun ada-goto-matching-decl-start (&optional noerror recursive)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3171 "Moves point to the matching declaration start of the current 'begin'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3172 If NOERROR is non-nil, it only returns nil if no match was found."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 (let ((nest-count 1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3174 (first (not recursive))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3175 (count-generic nil)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3176 (stop-at-when nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3177 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3178
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3179 ;; Ignore "when" most of the time, except if we are looking at the
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3180 ;; beginning of a block (structure: case .. is
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3181 ;; when ... =>
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3182 ;; begin ...
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3183 ;; exception ... )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3184 (if (looking-at "begin")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3185 (set 'stop-at-when t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3186
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3187 (if (or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3188 (looking-at "\\<\\(package\\|procedure\\|function\\)\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3189 (save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3190 (ada-search-ignore-string-comment
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3191 "\\<\\(package\\|procedure\\|function\\|generic\\)\\>" t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3192 (looking-at "generic")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3193 (set 'count-generic t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3194
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (not (zerop nest-count))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3198 (ada-search-ignore-string-comment ada-matching-decl-start-re t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 ((looking-at "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (ada-goto-matching-start 1 noerror)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3206
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3207 ;; In some case, two begin..end block can follow each other closely,
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3208 ;; which we have to detect, as in
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3209 ;; procedure P is
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3210 ;; procedure Q is
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3211 ;; begin
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3212 ;; end;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3213 ;; begin -- here we should go to procedure, not begin
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3214 ;; end
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3215
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3216 (if (looking-at "begin")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3217 (let ((loop-again t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3218 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3219 (while loop-again
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3220 ;; If begin was just there as the beginning of a block
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3221 ;; (with no declare) then do nothing, otherwise just
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3222 ;; register that we have to find the statement that
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3223 ;; required the begin
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3224
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3225 (ada-search-ignore-string-comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3226 "\\<\\(declare\\|begin\\|end\\|procedure\\|function\\|task\\|package\\)\\>"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3227 t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3228
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3229 (if (looking-at "end")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3230 (ada-goto-matching-decl-start noerror t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3231
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3232 (set 'loop-again nil)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3233 (unless (looking-at "begin")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3234 (set 'nest-count (1+ nest-count))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3235 ))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3236 )))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3238 ((looking-at "generic")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3239 (if count-generic
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3240 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3241 (set 'first nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3242 (set 'nest-count (1- nest-count)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3243 ;;
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3244 ((looking-at "if")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3245 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3246 (forward-word -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3247 (unless (looking-at "\\<end[ \t\n]*if\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3248 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3249 (set 'nest-count (1- nest-count))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3250 (set 'first nil)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3251
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3252 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3253 ((looking-at "declare\\|generic")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3254 (set 'nest-count (1- nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3255 (set 'first nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3256 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257 ((looking-at "is")
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3258 ;; check if it is only a type definition, but not a protected
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3259 ;; type definition, which should be handled like a procedure.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3260 (if (or (looking-at "is[ \t]+<>")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3261 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3262 (forward-comment -10000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3263 (forward-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3264
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3265 ;; Detect if we have a closing parenthesis (Could be
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3266 ;; either the end of subprogram parameters or (<>)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3267 ;; in a type definition
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3268 (if (= (char-after) ?\))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3269 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3270 (forward-char 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3271 (backward-sexp 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3272 (forward-comment -10000)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3273 ))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3274 (skip-chars-backward "a-zA-Z0-9_.'")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3275 (ada-goto-previous-word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3276 (and
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3277 (looking-at "\\<\\(sub\\)?type\\>")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3278 (save-match-data
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3279 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3280 (not (looking-at "\\<protected\\>"))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3281 )) ; end of `or'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282 (goto-char (match-beginning 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3283 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3284 (set 'nest-count (1- nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3285 (set 'first nil))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3286
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3287 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3288 ((looking-at "new")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3289 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3290 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3291 (looking-at "is"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3292 (goto-char (match-beginning 0))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3293 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3294 ((and first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3295 (looking-at "begin"))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3296 (set 'nest-count 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3297 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3298 ((looking-at "when")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3299 (if stop-at-when
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3300 (set 'nest-count (1- nest-count)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3301 (set 'first nil))
10705
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 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3304 (set 'nest-count (1+ nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3305 (set 'first nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3306
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3307 );; end of loop
10705
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 ;; check if declaration-start is really found
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3310 (if (and
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3311 (zerop nest-count)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3312 (if (looking-at "is")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3313 (ada-search-ignore-string-comment ada-subprog-start-re t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3314 (looking-at "declare\\|generic")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3315 t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3316 (if noerror nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3317 (error "no matching proc/func/task/declare/package/protected")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3318 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3319
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3320 (defun ada-goto-matching-start (&optional nest-level noerror gotothen)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3321 "Moves point to the beginning of a block-start.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3322 Which block depends on the value of NEST-LEVEL, which defaults to zero. If
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3323 NOERROR is non-nil, it only returns nil if no matching start was found.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3324 If GOTOTHEN is non-nil, point moves to the 'then' following 'if'."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3325 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3326 (found nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3327 (pos nil))
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 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3331 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3333 (not found)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3334 (ada-search-ignore-string-comment ada-matching-start-re t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3335
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3336 (unless (and (looking-at "\\<record\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3337 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3338 (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3339 (looking-at "\\<null\\>")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3340 (progn
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3341 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3342 ;; calculate nest-depth
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3343 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3344 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3345 ;; found block end => increase nest depth
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3346 ((looking-at "end")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3347 (set 'nest-count (1+ nest-count)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3348
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3349 ;; found loop/select/record/case/if => check if it starts or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3350 ;; ends a block
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3351 ((looking-at "loop\\|select\\|record\\|case\\|if")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3352 (set 'pos (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3353 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3354 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3355 ;; check if keyword follows 'end'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3356 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3357 (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3358 (if (looking-at "\\<end\\>[ \t]*[^;]")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3359 ;; it ends a block => increase nest depth
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3360 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3361 (set 'nest-count (1+ nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3362 (set 'pos (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3363 ;; it starts a block => decrease nest depth
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3364 (set 'nest-count (1- nest-count))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3365 (goto-char pos))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3366
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3367 ;; found package start => check if it really is a block
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3368 ((looking-at "package")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3369 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3370 ;; ignore if this is just a renames statement
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3371 (let ((current (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3372 (pos (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3373 "\\<\\(is\\|renames\\|;\\)\\>" nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3374 (if pos
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3375 (goto-char (car pos))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3376 (error (concat
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3377 "No matching 'is' or 'renames' for 'package' at"
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3378 " line "
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3379 (number-to-string (count-lines (point-min)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3380 (1+ current)))))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3381 (unless (looking-at "renames")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3382 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3383 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3384 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3385 ;; ignore it if it is only a declaration with 'new'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3386 (if (not (looking-at "\\<\\(new\\|separate\\)\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3387 (set 'nest-count (1- nest-count)))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3388 ;; found task start => check if it has a body
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3389 ((looking-at "task")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3390 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3391 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3392 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3393 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3394 ((looking-at "\\<body\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3395 ((looking-at "\\<type\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3396 ;; In that case, do nothing if there is a "is"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3397 (forward-word 2);; skip "type"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3398 (ada-goto-next-non-ws);; skip type name
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3399
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3400 ;; Do nothing if we are simply looking at a simple
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3401 ;; "task type name;" statement with no block
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3402 (unless (looking-at ";")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3403 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3404 ;; Skip the parameters
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3405 (if (looking-at "(")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3406 (ada-search-ignore-string-comment ")" nil))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3407 (let ((tmp (ada-search-ignore-string-comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3408 "\\<\\(is\\|;\\)\\>" nil)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3409 (if tmp
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3410 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3411 (goto-char (car tmp))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3412 (if (looking-at "is")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3413 (set 'nest-count (1- nest-count)))))))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3414 (t
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3415 ;; Check if that task declaration had a block attached to
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3416 ;; it (i.e do nothing if we have just "task name;")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3417 (unless (progn (forward-word 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3418 (looking-at "[ \t]*;"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3419 (set 'nest-count (1- nest-count)))))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3420 ;; all the other block starts
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3421 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3422 (set 'nest-count (1- nest-count)))) ; end of 'cond'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3423
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3424 ;; match is found, if nest-depth is zero
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3425 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3426 (set 'found (zerop nest-count))))) ; end of loop
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3427
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3428 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 ;; match found => is there anything else to do ?
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 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 (cond
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 ;; found 'if' => skip to 'then', if it's on a separate line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436 ;; and GOTOTHEN is non-nil
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 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3439 gotothen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3440 (looking-at "if")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3441 (save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3442 (ada-search-ignore-string-comment "then" nil nil nil
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3443 'word-search-forward)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3444 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3445 (looking-at "\\<then\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3446 (goto-char (match-beginning 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3447 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3448 ;; found 'do' => skip back to 'accept'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3449 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3450 ((looking-at "do")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3451 (unless (ada-search-ignore-string-comment "accept" t nil nil
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3452 'word-search-backward)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3453 (error "missing 'accept' in front of 'do'"))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3454 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3455
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3456 (if noerror
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3457 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3458 (error "no matching start")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3459
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3460
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3461 (defun ada-goto-matching-end (&optional nest-level noerror)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3462 "Moves point to the end of a block.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3463 Which block depends on the value of NEST-LEVEL, which defaults to zero.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3464 If NOERROR is non-nil, it only returns nil if found no matching start."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3465 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3466 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3467
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3468 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469 ;; search forward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3470 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3471 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3473 (ada-search-ignore-string-comment
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3474 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3475 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3476 (regexp-opt '("end" "loop" "select" "begin" "case"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3477 "if" "task" "package" "record" "do") t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3478 "\\>")) nil))
10705
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 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3481 ;; calculate nest-depth
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 (backward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3484 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3485 ;; found block end => decrease nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3486 ((looking-at "\\<end\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3487 (set 'nest-count (1- nest-count))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3488 ;; skip the following keyword
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3489 (if (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 (skip-chars-forward "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3491 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 (looking-at "\\<\\(loop\\|select\\|record\\|case\\|if\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 (forward-word 1)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494 ;; found package start => check if it really starts a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495 ((looking-at "\\<package\\>")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3496 (ada-search-ignore-string-comment "is" nil nil nil
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3497 'word-search-forward)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3499 ;; ignore and skip it if it is only a 'new' package
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3500 (if (looking-at "\\<new\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3501 (goto-char (match-end 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3502 (set 'nest-count (1+ nest-count))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3503 ;; all the other block starts
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3505 (set 'nest-count (1+ nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3506 (forward-word 1))) ; end of 'cond'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 ;; match is found, if nest-depth is zero
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3509 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3510 (set 'found (zerop nest-count))) ; end of loop
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3511
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3512 (if found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3513 t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3514 (if noerror
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3515 nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3516 (error "no matching end")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3517 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3518
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3519
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520 (defun ada-search-ignore-string-comment
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3521 (search-re &optional backward limit paramlists search-func)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3522 "Regexp-search for SEARCH-RE, ignoring comments, strings.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3523 If PARAMLISTS is nil, ignore parameter lists. Returns a cons cell of
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3524 begin and end of match data or nil, if not found.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3525 The search is done using SEARCH-FUNC, which should search backward if
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3526 BACKWARD is non-nil, forward otherwise. SEARCH-FUNC can be optimized in case
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3527 we are searching for a constant string.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3528 The search stops at pos LIMIT.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3529 Point is moved at the beginning of the search-re."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3530 (let (found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3531 begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3532 end
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3533 parse-result
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3534 (previous-syntax-table (syntax-table)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3535
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3536 (unless search-func
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3537 (set 'search-func (if backward 're-search-backward 're-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3540 ;; search until found or end-of-buffer
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3541 ;; We have to test that we do not look further than limit
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3542 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3543 (set-syntax-table ada-mode-symbol-syntax-table)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544 (while (and (not found)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3545 (or (not limit)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3546 (or (and backward (<= limit (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3547 (>= limit (point))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3548 (funcall search-func search-re limit 1))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3549 (set 'begin (match-beginning 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3550 (set 'end (match-end 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3551
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3552 (set 'parse-result (parse-partial-sexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3553 (save-excursion (beginning-of-line) (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3554 (point)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3555
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3556 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3557 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3558 ;; If inside a string, skip it (and the following comments)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3559 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3560 ((ada-in-string-p parse-result)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3561 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3562 (search-backward "\"" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3563 (goto-char (nth 8 parse-result)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3564 (unless backward (forward-sexp 1)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3565 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3566 ;; If inside a comment, skip it (and the following comments)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3567 ;; There is a special code for comments at the end of the file
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3569 ((ada-in-comment-p parse-result)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3570 (if ada-xemacs
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3571 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3572 (forward-line 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3573 (beginning-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3574 (forward-comment -1))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3575 (goto-char (nth 8 parse-result)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3576 (unless backward
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3577 ;; at the end of the file, it is not possible to skip a comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3578 ;; so we just go at the end of the line
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3579 (if (forward-comment 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3580 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3581 (forward-comment 1000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3582 (beginning-of-line))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3583 (end-of-line))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3584 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3585 ;; directly in front of a comment => skip it, if searching forward
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3586 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3587 ((and (= (char-after begin) ?-) (= (char-after (1+ begin)) ?-))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3588 (unless backward (progn (forward-char -1) (forward-comment 1000))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3589
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3590 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3591 ;; found a parameter-list but should ignore it => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3593 ((and (not paramlists) (ada-in-paramlist-p))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3594 (if backward
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3595 (search-backward "(" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3596 (search-forward ")" nil t)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3598 ;; found what we were looking for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3601 (set 'found t)))) ; end of loop
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3602
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3603 (set-syntax-table previous-syntax-table)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606 (cons begin end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3607 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3609 ;; -------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3610 ;; -- Testing the position of the cursor
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3611 ;; -------------------------------------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3612
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3613 (defun ada-in-decl-p ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3614 "Returns t if point is inside a declarative part.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3615 Assumes point to be at the end of a statement."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3616 (or (ada-in-paramlist-p)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3617 (save-excursion
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3618 (ada-goto-matching-decl-start t))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621 (defun ada-looking-at-semi-or ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3622 "Returns t if looking-at an 'or' following a semicolon."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 (and (looking-at "\\<or\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628 (looking-at "\\<or\\>")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3629
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3630
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 (defun ada-looking-at-semi-private ()
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3632 "Returns t if looking at the start of a private section in a package.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3633 Returns nil if the private is part of the package name, as in
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3634 'private package A is...' (this can only happen at top level)."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636 (and (looking-at "\\<private\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3637 (not (looking-at "\\<private[ \t]*\\(package\\|generic\\)"))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3638
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3639 ;; Make sure this is the start of a private section (ie after
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3640 ;; a semicolon or just after the package declaration, but not
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3641 ;; after a 'type ... is private' or 'is new ... with private'
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3642 (progn (forward-comment -1000)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3643 (or (= (char-before) ?\;)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3644 (and (forward-word -3)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3645 (looking-at "\\<package\\>")))))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3646
10705
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 (defun ada-in-paramlist-p ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3649 "Returns t if point is inside a parameter-list."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3650 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 (and
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3652 (ada-search-ignore-string-comment "(\\|)" t nil t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 ;; inside parentheses ?
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3654 (= (char-after) ?\()
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3655
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3656 ;; We could be looking at two things here:
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3657 ;; operator definition: function "." (
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3658 ;; subprogram definition: procedure .... (
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3659 ;; Let's skip back over the first one
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3660 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3661 (skip-syntax-backward " ")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3662 (if (= (char-before) ?\")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3663 (backward-char 3)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3664 (backward-word 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3665 t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3666
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3667 ;; and now over the second one
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3668 (backward-word 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3669
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3670 ;; We should ignore the case when the reserved keyword is in a
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3671 ;; comment (for instance, when we have:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3672 ;; -- .... package
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3673 ;; Test (A)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3674 ;; we should return nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3675
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3676 (not (ada-in-string-or-comment-p))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3677
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3678 ;; right keyword two words before parenthesis ?
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3679 ;; Type is in this list because of discriminants
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3680 (looking-at (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3681 (concat "\\<\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3682 "procedure\\|function\\|body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3683 "task\\|entry\\|accept\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3684 "access[ \t]+procedure\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3685 "access[ \t]+function\\|"
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3686 "pragma\\|"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3687 "type\\)\\>"))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3689 (defun ada-search-ignore-complex-boolean (regexp backwardp)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3690 "Like `ada-search-ignore-string-comment', except that it also ignores
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3691 boolean expressions 'and then' and 'or else'."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3692 (let (result)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3693 (while (and (set 'result (ada-search-ignore-string-comment regexp backwardp))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3694 (save-excursion (forward-word -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3695 (looking-at "and then\\|or else"))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3696 result))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3697
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3698 (defun ada-in-open-paren-p ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3699 "Returns the position of the first non-ws behind the last unclosed
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3700 parenthesis, or nil."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3701 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3702 (let ((parse (parse-partial-sexp
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3703 (point)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3704 (or (car (ada-search-ignore-complex-boolean
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3705 "\\<\\(;\\|is\\|then\\|loop\\|begin\\|else\\)\\>"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3706 t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3707 (point-min)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3708
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3709 (if (nth 1 parse)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3710 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3711 (goto-char (1+ (nth 1 parse)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3712 (skip-chars-forward " \t")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3713 (point))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3714
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3716 ;; -----------------------------------------------------------
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3717 ;; -- Behavior Of TAB Key
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3718 ;; -----------------------------------------------------------
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3719
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3720 (defun ada-tab ()
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3721 "Do indenting or tabbing according to `ada-tab-policy'.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3722 In Transient Mark mode, if the mark is active, operate on the contents
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3723 of the region. Otherwise, operates only on the current line."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3724 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3725 (cond ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3726 ((eq ada-tab-policy 'indent-auto)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3727 ;; transient-mark-mode and mark-active are not defined in XEmacs
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3728 (if (or (and ada-xemacs (funcall (symbol-function 'region-active-p)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3729 (and (not ada-xemacs)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3730 (symbol-value 'transient-mark-mode)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3731 (symbol-value 'mark-active)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3732 (ada-indent-region (region-beginning) (region-end))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3733 (ada-indent-current)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3734 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3735 ))
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 (defun ada-untab (arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3738 "Delete leading indenting according to `ada-tab-policy'."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3739 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3740 (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3741 ((eq ada-tab-policy 'indent-auto) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3742 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3743 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3744
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3745 (defun ada-indent-current-function ()
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3746 "Ada mode version of the indent-line-function."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3747 (interactive "*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3748 (let ((starting-point (point-marker)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3749 (beginning-of-line)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3750 (ada-tab)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3751 (if (< (point) starting-point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3752 (goto-char starting-point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3753 (set-marker starting-point nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3754 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3755
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3756 (defun ada-tab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757 "Indent current line to next tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3758 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3759 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3760 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3761 (insert-char ? ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 (if (save-excursion (= (point) (progn (beginning-of-line) (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3763 (forward-char ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3765 (defun ada-untab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3766 "indent current line to previous tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3767 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3768 (let ((bol (save-excursion (progn (beginning-of-line) (point))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3769 (eol (save-excursion (progn (end-of-line) (point)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3770 (indent-rigidly bol eol (- 0 ada-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3773
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3774 ;; ------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3775 ;; -- Miscellaneous
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3776 ;; ------------------------------------------------------------
10705
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 (defun ada-remove-trailing-spaces ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3779 "Remove trailing spaces in the whole buffer."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3780 (interactive)
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3781 (save-match-data
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3782 (save-excursion
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3783 (save-restriction
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3784 (widen)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3785 (goto-char (point-min))
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3786 (while (re-search-forward "[ \t]+$" (point-max) t)
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3787 (replace-match "" nil nil))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3788
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3789 (defun ada-gnat-style ()
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3790 "Clean up comments, `(' and `,' for GNAT style checking switch."
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3791 (interactive)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3792 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3793 (goto-char (point-min))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3794 (while (re-search-forward "--[ \t]*\\([^-]\\)" nil t)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3795 (replace-match "-- \\1"))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3796 (goto-char (point-min))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3797 (while (re-search-forward "\\>(" nil t)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3798 (replace-match " ("))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3799 (goto-char (point-min))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3800 (while (re-search-forward "([ \t]+" nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3801 (replace-match "("))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3802 (goto-char (point-min))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3803 (while (re-search-forward ")[ \t]+)" nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3804 (replace-match "))"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3805 (goto-char (point-min))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3806 (while (re-search-forward "\\>:" nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3807 (replace-match " :"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3808 (goto-char (point-min))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3809 (while (re-search-forward ",\\<" nil t)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3810 (replace-match ", "))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3811 (goto-char (point-min))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3812 (while (re-search-forward "[ \t]*\\.\\.[ \t]*" nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3813 (replace-match " .. "))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3814 (goto-char (point-min))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3815 (while (re-search-forward "[ \t]*\\([-:+*/]\\)[ \t]*" nil t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3816 (if (not (ada-in-string-or-comment-p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3817 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3818 (forward-char -1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3819 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3820 ((looking-at "/=")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3821 (replace-match " /= "))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3822 ((looking-at ":=")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3823 (replace-match ":= "))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3824 ((not (looking-at "--"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3825 (replace-match " \\1 ")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3826 (forward-char 2))))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3827 ))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3828
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3829
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3830
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3831 ;; -------------------------------------------------------------
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3832 ;; -- Moving To Procedures/Packages/Statements
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3833 ;; -------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3834
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3835 (defun ada-move-to-start ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3836 "Moves point to the matching start of the current Ada structure."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3837 (interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3838 (let ((pos (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3839 (previous-syntax-table (syntax-table)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3840 (unwind-protect
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3841 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3842 (set-syntax-table ada-mode-symbol-syntax-table)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3843
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3844 (message "searching for block start ...")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3845 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3846 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3847 ;; do nothing if in string or comment or not on 'end ...;'
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3848 ;; or if an error occurs during processing
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3849 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3850 (or
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3851 (ada-in-string-or-comment-p)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3852 (and (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3853 (or (looking-at "[ \t]*\\<end\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3854 (backward-word 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3855 (or (looking-at "[ \t]*\\<end\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3856 (backward-word 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3857 (or (looking-at "[ \t]*\\<end\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3858 (error "not on end ...;")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3859 (ada-goto-matching-start 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3860 (set 'pos (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3861
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3862 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3863 ;; on 'begin' => go on, according to user option
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3864 ;;
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3865 ada-move-to-declaration
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3866 (looking-at "\\<begin\\>")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3867 (ada-goto-matching-decl-start)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3868 (set 'pos (point))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3869
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3870 ) ; end of save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3871
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3872 ;; now really move to the found position
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3873 (goto-char pos)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3874 (message "searching for block start ... done"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3875
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3876 ;; restore syntax-table
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3877 (set-syntax-table previous-syntax-table))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3878
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3879 (defun ada-move-to-end ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3880 "Moves point to the matching end of the block around point.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3881 Moves to 'begin' if in a declarative part."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3882 (interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3883 (let ((pos (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3884 (previous-syntax-table (syntax-table)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3885 (unwind-protect
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3886 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3887 (set-syntax-table ada-mode-symbol-syntax-table)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3888
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3889 (message "searching for block end ...")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3890 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3891
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3892 (forward-char 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3893 (cond
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3894 ;; directly on 'begin'
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3895 ((save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3896 (ada-goto-previous-word)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3897 (looking-at "\\<begin\\>"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3898 (ada-goto-matching-end 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3899 ;; on first line of defun declaration
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3900 ((save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3901 (and (ada-goto-stmt-start)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3902 (looking-at "\\<function\\>\\|\\<procedure\\>" )))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3903 (ada-search-ignore-string-comment "begin" nil nil nil
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3904 'word-search-forward))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3905 ;; on first line of task declaration
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3906 ((save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3907 (and (ada-goto-stmt-start)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3908 (looking-at "\\<task\\>" )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3909 (forward-word 1)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3910 (ada-goto-next-non-ws)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3911 (looking-at "\\<body\\>")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3912 (ada-search-ignore-string-comment "begin" nil nil nil
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3913 'word-search-forward))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3914 ;; accept block start
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3915 ((save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3916 (and (ada-goto-stmt-start)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3917 (looking-at "\\<accept\\>" )))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3918 (ada-goto-matching-end 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3919 ;; package start
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3920 ((save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3921 (and (ada-goto-matching-decl-start t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3922 (looking-at "\\<package\\>")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3923 (ada-goto-matching-end 1))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3924 ;; inside a 'begin' ... 'end' block
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3925 ((save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3926 (ada-goto-matching-decl-start t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3927 (ada-search-ignore-string-comment "begin" nil nil nil
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3928 'word-search-forward))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3929 ;; (hopefully ;-) everything else
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3930 (t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3931 (ada-goto-matching-end 1)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3932 (set 'pos (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3933 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3934
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3935 ;; now really move to the position found
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3936 (goto-char pos)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3937 (message "searching for block end ... done"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3938
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3939 ;; restore syntax-table
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3940 (set-syntax-table previous-syntax-table))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
3941
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942 (defun ada-next-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3943 "Moves point to next procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3944 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3945 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3946 (if (re-search-forward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3947 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3948 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 (defun ada-previous-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3951 "Moves point to previous procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3952 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3953 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3954 (if (re-search-backward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3955 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3956 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3957
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3958 (defun ada-next-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3959 "Moves point to next package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3960 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3961 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3962 (if (re-search-forward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3963 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3964 (error "No more packages")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3965
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3966 (defun ada-previous-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967 "Moves point to previous package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3968 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3969 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3970 (if (re-search-backward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3971 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3972 (error "No more packages")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3973
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3974
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3975 ;; ------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3976 ;; -- Define keymap and menus for Ada
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3977 ;; -------------------------------------------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3978
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3979 (defun ada-create-keymap ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3980 "Create the keymap associated with the Ada mode."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3981
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3982 ;; Indentation and Formatting
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3983 (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent-conditional)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3984 (define-key ada-mode-map "\C-m" 'ada-indent-newline-indent-conditional)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3985 (define-key ada-mode-map "\t" 'ada-tab)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3986 (define-key ada-mode-map "\C-c\t" 'ada-justified-indent-current)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3987 (define-key ada-mode-map "\C-c\C-l" 'ada-indent-region)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3988 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3989 (define-key ada-mode-map '(shift tab) 'ada-untab)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3990 (define-key ada-mode-map [S-tab] 'ada-untab))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3991 (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3992 ;; We don't want to make meta-characters case-specific.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3993
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3994 ;; Movement
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3995 (define-key ada-mode-map "\M-\C-e" 'ada-next-procedure)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3996 (define-key ada-mode-map "\M-\C-a" 'ada-previous-procedure)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3997 (define-key ada-mode-map "\C-c\C-a" 'ada-move-to-start)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3998 (define-key ada-mode-map "\C-c\C-e" 'ada-move-to-end)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3999
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4000 ;; Compilation
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4001 (unless (lookup-key ada-mode-map "\C-c\C-c")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4002 (define-key ada-mode-map "\C-c\C-c" 'compile))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4003
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4004 ;; Casing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4005 (define-key ada-mode-map "\C-c\C-b" 'ada-adjust-case-buffer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4006 (define-key ada-mode-map "\C-c\C-t" 'ada-case-read-exceptions)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4007 (define-key ada-mode-map "\C-c\C-y" 'ada-create-case-exception)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4008
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4009 ;; On XEmacs, you can easily specify whether DEL should deletes
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4010 ;; one character forward or one character backward. Take this into
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4011 ;; account
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4012 (if (boundp 'delete-key-deletes-forward)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4013 (define-key ada-mode-map [backspace] 'backward-delete-char-untabify)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4014 (define-key ada-mode-map "\177" 'backward-delete-char-untabify))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4015
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4016 ;; Make body
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4017 (define-key ada-mode-map "\C-c\C-n" 'ada-make-subprogram-body)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4018
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4019 ;; Use predefined function of Emacs19 for comments (RE)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4020 (define-key ada-mode-map "\C-c;" 'comment-region)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4021 (define-key ada-mode-map "\C-c:" 'ada-uncomment-region)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4022 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4023
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4024
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4025 (defun ada-create-menu ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4026 "Create the ada menu as shown in the menu bar.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4027 This function is designed to be extensible, so that each compiler-specific file
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4028 can add its own items."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4029 ;; Note that the separators must have different length in the submenus
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4030 (autoload 'easy-menu-define "easymenu")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4031
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4032 (let ((m '("Ada"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4033 ("Help" ["Ada Mode" (info "ada-mode") t])))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4034 (option '(["Auto Casing" (setq ada-auto-case (not ada-auto-case))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4035 :style toggle :selected ada-auto-case]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4036 ["Auto Indent After Return"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4037 (setq ada-indent-after-return (not ada-indent-after-return))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4038 :style toggle :selected ada-indent-after-return]))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4039 (goto '(["Next compilation error" next-error t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4040 ["Previous Package" ada-previous-package t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4041 ["Next Package" ada-next-package t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4042 ["Previous Procedure" ada-previous-procedure t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4043 ["Next Procedure" ada-next-procedure t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4044 ["Goto Start Of Statement" ada-move-to-start t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4045 ["Goto End Of Statement" ada-move-to-end t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4046 ["-" nil nil]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4047 ["Other File" ff-find-other-file t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4048 ["Other File Other Window" ada-ff-other-window t]))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4049 (edit '(["Indent Line" ada-indent-current-function t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4050 ["Justify Current Indentation" ada-justified-indent-current t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4051 ["Indent Lines in Selection" ada-indent-region t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4052 ["Indent Lines in File" (ada-indent-region (point-min) (point-max)) t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4053 ["Format Parameter List" ada-format-paramlist t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4054 ["-" nil nil]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4055 ["Comment Selection" comment-region t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4056 ["Uncomment Selection" ada-uncomment-region t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4057 ["--" nil nil]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4058 ["Fill Comment Paragraph" fill-paragraph t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4059 ["Fill Comment Paragraph Justify" ada-fill-comment-paragraph-justify t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4060 ["Fill Comment Paragraph Postfix" ada-fill-comment-paragraph-postfix t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4061 ["---" nil nil]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4062 ["Adjust Case Selection" ada-adjust-case-region t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4063 ["Adjust Case Buffer" ada-adjust-case-buffer t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4064 ["Create Case Exception" ada-create-case-exception t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4065 ["Reload Case Exceptions" ada-case-read-exceptions t]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4066 ["----" nil nil]
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4067 ["Make body for subprogram" ada-make-subprogram-body t]))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4068
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4069 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4070
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4071 ;; Option menu present only if in Ada mode
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4072 (set 'm (append m (list (append (list "Options"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4073 (if ada-xemacs :included :visible)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4074 '(string= mode-name "Ada"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4075 option))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4076
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4077 ;; Customize menu always present
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4078 (set 'm (append m '(["Customize" (customize-group 'ada)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4079 (>= emacs-major-version 20)])))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4080
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4081 ;; Goto and Edit menus present only if in Ada mode
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4082 (set 'm (append m (list (append (list "Goto"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4083 (if ada-xemacs :included :visible)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4084 '(string= mode-name "Ada"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4085 goto)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4086 (append (list "Edit"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4087 (if ada-xemacs :included :visible)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4088 '(string= mode-name "Ada"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4089 edit))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4090
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4091 (easy-menu-define ada-mode-menu ada-mode-map "Menu keymap for Ada mode" m)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4092 (if ada-xemacs
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4093 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4094 (easy-menu-add ada-mode-menu ada-mode-map)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4095 (define-key ada-mode-map [menu-bar] ada-mode-menu)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4096 (set 'mode-popup-menu (cons "Ada mode" ada-mode-menu)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4097 )
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4098 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4099
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4100
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4101 ;; -------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4102 ;; Commenting/Uncommenting code
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4103 ;; The following two calls are provided to enhance the standard
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4104 ;; comment-region function, which only allows uncommenting if the
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4105 ;; comment is at the beginning of a line. If the line have been re-indented,
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4106 ;; we are unable to use comment-region, which makes no sense.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4107 ;;
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4108 ;; In addition, we provide an interface to the standard comment handling
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4109 ;; function for justifying the comments.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4110 ;; -------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4111
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4112 (defadvice comment-region (before ada-uncomment-anywhere)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4113 (if (and arg
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4114 (< arg 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4115 (string= mode-name "Ada"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4116 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4117 (let ((cs (concat "^[ \t]*" (regexp-quote comment-start))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4118 (goto-char beg)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4119 (while (re-search-forward cs end t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4120 (replace-match comment-start))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4121 ))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4122
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4123 (defun ada-uncomment-region (beg end &optional arg)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4124 "Delete `comment-start' at the beginning of a line in the region."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4125 (interactive "r\nP")
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4126
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4127 ;; This advice is not needed anymore with Emacs21. However, for older
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4128 ;; versions, as well as for XEmacs, we still need to enable it.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4129 (if (or (<= emacs-major-version 20) (boundp 'running-xemacs))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4130 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4131 (ad-activate 'comment-region)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4132 (comment-region beg end (- (or arg 1)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4133 (ad-deactivate 'comment-region))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4134 (comment-region beg end (list (- (or arg 1))))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4135
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4136 (defun ada-fill-comment-paragraph-justify ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4137 "Fills current comment paragraph and justifies each line as well."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4138 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4139 (ada-fill-comment-paragraph 'full))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4140
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4141 (defun ada-fill-comment-paragraph-postfix ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4142 "Fills current comment paragraph and justifies each line as well.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4143 Adds `ada-fill-comment-postfix' at the end of each line."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4144 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4145 (ada-fill-comment-paragraph 'full t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4146
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4147 (defun ada-fill-comment-paragraph (&optional justify postfix)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4148 "Fills the current comment paragraph.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4149 If JUSTIFY is non-nil, each line is justified as well.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4150 If POSTFIX and JUSTIFY are non-nil, `ada-fill-comment-postfix' is appended
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4151 to each filled and justified line.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4152 The paragraph is indented on the first line."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4153 (interactive "P")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4154
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4155 ;; check if inside comment or just in front a comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4156 (if (and (not (ada-in-comment-p))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4157 (not (looking-at "[ \t]*--")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4158 (error "not inside comment"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4159
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4160 (let* ((indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4161 (from)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4162 (to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4163 (opos (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4164
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4165 ;; Sets this variable to nil, otherwise it prevents
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4166 ;; fill-region-as-paragraph to work on Emacs <= 20.2
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4167 (parse-sexp-lookup-properties nil)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4168
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4169 fill-prefix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4170 (fill-column (current-fill-column)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4171
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4172 ;; Find end of paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4173 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4174 (while (and (not (eobp)) (looking-at "--[ \t]*[^ \t\n]"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4175 (forward-line 1)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4176
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4177 ;; If we were at the last line in the buffer, create a dummy empty
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4178 ;; line at the end of the buffer.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4179 (if (eolp)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4180 (insert "\n")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4181 (back-to-indentation)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4182 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4183 (set 'to (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4184 (goto-char opos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4185
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4186 ;; Find beginning of paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4187 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4188 (while (and (not (bobp)) (looking-at "--[ \t]*[^ \t\n]"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4189 (forward-line -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4190 (back-to-indentation))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4191
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4192 ;; We want one line to above the first one, unless we are at the beginning
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4193 ;; of the buffer
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4194 (unless (bobp)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4195 (forward-line 1))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4196 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4197 (set 'from (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4198
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4199 ;; Calculate the indentation we will need for the paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4200 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4201 (set 'indent (current-column))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4202 ;; unindent the first line of the paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4203 (delete-region from (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4204
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4205 ;; Remove the old postfixes
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4206 (goto-char from)
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4207 (while (re-search-forward "--\n" to t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4208 (replace-match "\n"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4209
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4210 ;; Remove the old prefixes (so that the number of spaces after -- is not
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4211 ;; relevant), except on the first one since `fill-region-as-paragraph'
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4212 ;; would not put it back on the first line.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4213 (goto-char (+ from 2))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4214 (while (re-search-forward "^-- *" to t)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4215 (replace-match " "))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4216
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4217 (goto-char (1- to))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4218 (set 'to (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4219
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4220 ;; Indent and justify the paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4221 (set 'fill-prefix ada-fill-comment-prefix)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4222 (set-left-margin from to indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4223 (if postfix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4224 (set 'fill-column (- fill-column (length ada-fill-comment-postfix))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4225
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4226 (fill-region-as-paragraph from to justify)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4227
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4228 ;; Add the postfixes if required
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4229 (if postfix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4230 (save-restriction
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4231 (goto-char from)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4232 (narrow-to-region from to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4233 (while (not (eobp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4234 (end-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4235 (insert-char ? (- fill-column (current-column)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4236 (insert ada-fill-comment-postfix)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4237 (forward-line))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4238 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4239
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4240 ;; In Emacs <= 20.2 and XEmacs <=20.4, there is a bug, and a newline is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4241 ;; inserted at the end. Delete it
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4242 (if (or ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4243 (<= emacs-major-version 19)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4244 (and (= emacs-major-version 20)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4245 (<= emacs-minor-version 2)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4246 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4247 (goto-char to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4248 (end-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4249 (delete-char 1)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4250
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4251 (goto-char opos)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4252
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4253
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4254 ;; ---------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4255 ;; support for find-file.el
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4256 ;; These functions are used by find-file to guess the file names from
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4257 ;; unit names, and to find the other file (spec or body) from the current
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4258 ;; file (body or spec).
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4259 ;; It is also used to find in which function we are, so as to put the
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4260 ;; cursor at the correct position.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4261 ;; Standard Ada does not force any relation between unit names and file names,
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4262 ;; so some of these functions can only be a good approximation. However, they
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4263 ;; are also overriden in `ada-xref'.el when we know that the user is using
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4264 ;; GNAT.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4265 ;; ---------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4266
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4267 ;; Overriden when we work with GNAT, to use gnatkrunch
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4268 (defun ada-make-filename-from-adaname (adaname)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4269 "Determine the filename in which ADANAME is found.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4270 This is a generic function, independent from any compiler."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4271 (while (string-match "\\." adaname)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4272 (set 'adaname (replace-match "-" t t adaname)))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4273 (downcase adaname)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4274 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4275
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4276 (defun ada-other-file-name ()
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4277 "Return the name of the other file.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4278 The name returned is the body if current-buffer is the spec, or the spec
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4279 otherwise."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4280
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4281 (let ((is-spec nil)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4282 (is-body nil)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4283 (suffixes ada-spec-suffixes)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4284 (name (buffer-file-name)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4285
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4286 ;; Guess whether we have a spec or a body, and get the basename of the
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4287 ;; file. Since the extension may not start with '.', we can not use
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4288 ;; file-name-extension
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4289 (while (and (not is-spec)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4290 suffixes)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4291 (if (string-match (concat "\\(.*\\)" (car suffixes) "$") name)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4292 (setq is-spec t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4293 name (match-string 1 name)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4294 (set 'suffixes (cdr suffixes)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4295
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4296 (if (not is-spec)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4297 (progn
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4298 (set 'suffixes ada-body-suffixes)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4299 (while (and (not is-body)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4300 suffixes)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4301 (if (string-match (concat "\\(.*\\)" (car suffixes) "$") name)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4302 (setq is-body t
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4303 name (match-string 1 name)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4304 (set 'suffixes (cdr suffixes)))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4305
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4306 ;; If this wasn't in either list, return name itself
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4307 (if (not (or is-spec is-body))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4308 name
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4309
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4310 ;; Else find the other possible names
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4311 (if is-spec
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4312 (set 'suffixes ada-body-suffixes)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4313 (set 'suffixes ada-spec-suffixes))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4314 (set 'is-spec name)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4315
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4316 (while suffixes
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4317 (if (file-exists-p (concat name (car suffixes)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4318 (set 'is-spec (concat name (car suffixes))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4319 (set 'suffixes (cdr suffixes)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4320
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4321 is-spec)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4322
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4323 (defun ada-which-function-are-we-in ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4324 "Return the name of the function whose definition/declaration point is in.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4325 Redefines the function `ff-which-function-are-we-in'."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4326 (set 'ff-function-name nil)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4327 (save-excursion
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4328 (end-of-line);; make sure we get the complete name
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4329 (if (or (re-search-backward ada-procedure-start-regexp nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4330 (re-search-backward ada-package-start-regexp nil t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4331 (set 'ff-function-name (match-string 0)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4332 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4333
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4334
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4335 (defvar ada-last-which-function-line -1
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4336 "Last on which ada-which-function was called")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4337 (defvar ada-last-which-function-subprog 0
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4338 "Last subprogram name returned by ada-which-function")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4339 (make-variable-buffer-local 'ada-last-which-function-subprog)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4340 (make-variable-buffer-local 'ada-last-which-function-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4341
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4342
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4343 (defun ada-which-function ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4344 "Returns the name of the function whose body the point is in.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4345 This function works even in the case of nested subprograms, whereas the
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4346 standard Emacs function which-function does not.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4347 Note that this function expects subprogram bodies to be terminated by
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4348 'end <name>;', not 'end;'.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4349 Since the search can be long, the results are cached."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4350
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4351 (let ((line (count-lines (point-min) (point)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4352 (pos (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4353 end-pos
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4354 func-name
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4355 found)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4356
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4357 ;; If this is the same line as before, simply return the same result
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4358 (if (= line ada-last-which-function-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4359 ada-last-which-function-subprog
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4360
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4361 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4362 ;; In case the current line is also the beginning of the body
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4363 (end-of-line)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4364 (while (and (ada-in-paramlist-p)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4365 (= (forward-line 1) 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4366 (end-of-line))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4367
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4368 ;; Can't simply do forward-word, in case the "is" is not on the
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4369 ;; same line as the closing parenthesis
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4370 (skip-chars-forward "is \t\n")
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4371
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4372 ;; No look for the closest subprogram body that has not ended yet.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4373 ;; Not that we expect all the bodies to be finished by "end <name",
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4374 ;; not simply "end"
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4375
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4376 (while (and (not found)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4377 (re-search-backward ada-imenu-subprogram-menu-re nil t))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4378 (set 'func-name (match-string 2))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4379 (if (and (not (ada-in-comment-p))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4380 (not (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4381 (goto-char (match-end 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4382 (looking-at "[ \t\n]*new"))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4383 (save-excursion
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4384 (if (ada-search-ignore-string-comment
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4385 (concat "end[ \t]+" func-name "[ \t]*;"))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4386 (set 'end-pos (point))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4387 (set 'end-pos (point-max)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4388 (if (>= end-pos pos)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4389 (set 'found func-name))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4390 )
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4391 (setq ada-last-which-function-line line
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4392 ada-last-which-function-subprog found)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4393 found))))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4394
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4395 (defun ada-ff-other-window ()
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4396 "Find other file in other window using `ff-find-other-file'."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4397 (interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4398 (and (fboundp 'ff-find-other-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4399 (ff-find-other-file t)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4400
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4401 (defun ada-set-point-accordingly ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4402 "Move to the function declaration that was set by
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4403 `ff-which-function-are-we-in'."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4404 (if ff-function-name
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4405 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4406 (goto-char (point-min))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4407 (unless (ada-search-ignore-string-comment
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4408 (concat ff-function-name "\\b") nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4409 (goto-char (point-min))))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4410
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4411 (defun ada-get-body-name (&optional spec-name)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4412 "Returns the file name for the body of SPEC-NAME.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4413 If SPEC-NAME is nil, returns the body for the current package.
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4414 Returns nil if no body was found."
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4415 (interactive)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4416
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4417 (unless spec-name (set 'spec-name (buffer-file-name)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4418
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4419 ;; If find-file.el was available, use its functions
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4420 (if (functionp 'ff-get-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4421 (ff-get-file-name ada-search-directories
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4422 (ada-make-filename-from-adaname
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4423 (file-name-nondirectory
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4424 (file-name-sans-extension spec-name)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4425 ada-body-suffixes)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4426 ;; Else emulate it very simply
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4427 (concat (ada-make-filename-from-adaname
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4428 (file-name-nondirectory
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4429 (file-name-sans-extension spec-name)))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4430 ".adb")))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4431
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4432
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4433 ;; ---------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4434 ;; support for font-lock.el
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4435 ;; Strings are a real pain in Ada because a single quote character is
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4436 ;; overloaded as a string quote and type/instance delimiter. By default, a
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4437 ;; single quote is given punctuation syntax in `ada-mode-syntax-table'.
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4438 ;; So, for Font Lock mode purposes, we mark single quotes as having string
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4439 ;; syntax when the gods that created Ada determine them to be.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4440 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4441 ;; This only works in Emacs. See the comments before the grammar functions
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4442 ;; at the beginning of this file for how this is done with XEmacs.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4443 ;; ----------------------------------------------------
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4444
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4445 (defconst ada-font-lock-syntactic-keywords
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4446 ;; Mark single quotes as having string quote syntax in 'c' instances.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4447 ;; As a special case, ''' will not be highlighted, but if we do not
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4448 ;; set this special case, then the rest of the buffer is highlighted as
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4449 ;; a string
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4450 ;; This sets the properties of the characters, so that ada-in-string-p
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4451 ;; correctly handles '"' too...
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4452 '(("\\('\\)[^'\n]\\('\\)" (1 (7 . ?')) (2 (7 . ?')))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4453 ("^[ \t]*\\(#\\(if\\|else\\|elsif\\|end\\)\\)" (1 (11 . ?\n)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4454 ))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4455
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4456 (defvar ada-font-lock-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4457 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4458 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4459 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4460 ;; handle "type T is access function return S;"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4461 (list "\\<\\(function[ \t]+return\\)\\>" '(1 font-lock-keyword-face) )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4462
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4463 ;; preprocessor line
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4464 (list "^[ \t]*\\(#.*\n\\)" '(1 font-lock-type-face t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4465
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4466 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4467 ;; accept, entry, function, package (body), protected (body|type),
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4468 ;; pragma, procedure, task (body) plus name.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4469 (list (concat
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4470 "\\<\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4471 "accept\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4472 "entry\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4473 "function\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4474 "package[ \t]+body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4475 "package\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4476 "pragma\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4477 "procedure\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4478 "protected[ \t]+body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4479 "protected[ \t]+type\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4480 "protected\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4481 "task[ \t]+body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4482 "task[ \t]+type\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4483 "task"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4484 "\\)\\>[ \t]*"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4485 "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4486 '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4487 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4488 ;; Optional keywords followed by a type name.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4489 (list (concat ; ":[ \t]*"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4490 "\\<\\(access[ \t]+all\\|access\\|constant\\|in[ \t]+out\\|in\\|out\\)\\>"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4491 "[ \t]*"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4492 "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4493 '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4494
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4495 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4496 ;; Main keywords, except those treated specially below.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4497 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4498 (regexp-opt
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4499 '("abort" "abs" "abstract" "accept" "access" "aliased" "all"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4500 "and" "array" "at" "begin" "case" "declare" "delay" "delta"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4501 "digits" "do" "else" "elsif" "entry" "exception" "exit" "for"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4502 "generic" "if" "in" "is" "limited" "loop" "mod" "not"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4503 "null" "or" "others" "private" "protected" "raise"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4504 "range" "record" "rem" "renames" "requeue" "return" "reverse"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4505 "select" "separate" "tagged" "task" "terminate" "then" "until"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4506 "when" "while" "xor") t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4507 "\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4508 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4509 ;; Anything following end and not already fontified is a body name.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4510 '("\\<\\(end\\)\\>\\([ \t]+\\)?\\(\\(\\sw\\|[_.]\\)+\\)?"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4511 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4512 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4513 ;; Keywords followed by a type or function name.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4514 (list (concat "\\<\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4515 "new\\|of\\|subtype\\|type"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4516 "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?[ \t]*\\((\\)?")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4517 '(1 font-lock-keyword-face)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4518 '(2 (if (match-beginning 4)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4519 font-lock-function-name-face
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4520 font-lock-type-face) nil t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4521 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4522 ;; Keywords followed by a (comma separated list of) reference.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4523 (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)\\>" ; "when" removed
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4524 "[ \t\n]*\\(\\(\\sw\\|[_.|, \t\n]\\)+\\)\\W")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4525 '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4526 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4527 ;; Goto tags.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4528 '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4529 ))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4530 "Default expressions to highlight in Ada mode.")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4531
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4532
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4533 ;; ---------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4534 ;; Support for outline.el
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4535 ;; ---------------------------------------------------------
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4536
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4537 (defun ada-outline-level ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4538 "This is so that `current-column` DTRT in otherwise-hidden text"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4539 ;; patch from Dave Love <fx@gnu.org>
24446
25556de3fe49 (ada-outline-level): Bind buffer-invisibility-spec.
Dave Love <fx@gnu.org>
parents: 24325
diff changeset
4540 (let (buffer-invisibility-spec)
25556de3fe49 (ada-outline-level): Bind buffer-invisibility-spec.
Dave Love <fx@gnu.org>
parents: 24325
diff changeset
4541 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4542 (back-to-indentation)
24446
25556de3fe49 (ada-outline-level): Bind buffer-invisibility-spec.
Dave Love <fx@gnu.org>
parents: 24325
diff changeset
4543 (current-column))))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4544
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4545 ;; ---------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4546 ;; Automatic generation of code
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4547 ;; The Ada-mode has a set of function to automatically generate a subprogram
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4548 ;; or package body from its spec.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4549 ;; These function only use a primary and basic algorithm, this could use a
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4550 ;; lot of improvement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4551 ;; When the user is using GNAT, we rather use gnatstub to generate an accurate
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4552 ;; body.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4553 ;; ----------------------------------------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4554
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4555 (defun ada-gen-treat-proc (match)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4556 "Make dummy body of a procedure/function specification.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4557 MATCH is a cons cell containing the start and end location of the last search
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4558 for ada-procedure-start-regexp."
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4559 (goto-char (car match))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4560 (let (func-found procname functype)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4561 (cond
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4562 ((or (looking-at "^[ \t]*procedure")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4563 (set 'func-found (looking-at "^[ \t]*function")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4564 ;; treat it as a proc/func
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4565 (forward-word 2)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4566 (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4567 (set 'procname (buffer-substring (point) (cdr match))) ; store proc name
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4568
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4569 ;; goto end of procname
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4570 (goto-char (cdr match))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4571
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4572 ;; skip over parameterlist
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4573 (unless (looking-at "[ \t\n]*\\(;\\|return\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4574 (forward-sexp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4575
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4576 ;; if function, skip over 'return' and result type.
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4577 (if func-found
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4578 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4579 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4580 (skip-chars-forward " \t\n")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4581 (set 'functype (buffer-substring (point)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4582 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4583 (skip-chars-forward
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4584 "a-zA-Z0-9_\.")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4585 (point))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4586 ;; look for next non WS
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4587 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4588 ((looking-at "[ \t]*;")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4589 (delete-region (match-beginning 0) (match-end 0));; delete the ';'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4590 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4591 (insert "is")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4592 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4593 (if func-found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4594 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4595 (insert "Result : " functype ";")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4596 (ada-indent-newline-indent)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4597 (insert "begin")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4598 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4599 (if func-found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4600 (insert "return Result;")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4601 (insert "null;"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4602 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4603 (insert "end " procname ";")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4604 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4605 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4606 ;; else
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4607 ((looking-at "[ \t\n]*is")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4608 ;; do nothing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4609 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4610 ((looking-at "[ \t\n]*rename")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4611 ;; do nothing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4612 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4613 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4614 (message "unknown syntax"))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4615 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4616 (if (looking-at "^[ \t]*task")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4617 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4618 (message "Task conversion is not yet implemented")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4619 (forward-word 2)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4620 (if (looking-at "[ \t]*;")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4621 (forward-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4622 (ada-move-to-end))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4623 ))))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4624
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4625 (defun ada-make-body ()
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4626 "Create an Ada package body in the current buffer.
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4627 The potential old buffer contents is deleted first, then we copy the
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4628 spec buffer in here and modify it to make it a body.
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4629 This function typically is to be hooked into `ff-file-created-hooks'."
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4630 (interactive)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4631 (delete-region (point-min) (point-max))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4632 (insert-buffer (car (cdr (buffer-list))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4633 (ada-mode)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4634
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4635 (let (found ada-procedure-or-package-start-regexp)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4636 (if (set 'found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4637 (ada-search-ignore-string-comment ada-package-start-regexp nil))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4638 (progn (goto-char (cdr found))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4639 (insert " body")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4640 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4641 (error "No package"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4642
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4643 (set 'ada-procedure-or-package-start-regexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4644 (concat ada-procedure-start-regexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4645 "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4646 ada-package-start-regexp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4647
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4648 (while (set 'found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4649 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4650 ada-procedure-or-package-start-regexp nil))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4651 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4652 (goto-char (car found))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4653 (if (looking-at ada-package-start-regexp)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4654 (progn (goto-char (cdr found))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4655 (insert " body"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4656 (ada-gen-treat-proc found))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4657
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4658
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4659 (defun ada-make-subprogram-body ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4660 "Make one dummy subprogram body from spec surrounding point."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4661 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4662 (let* ((found (re-search-backward ada-procedure-start-regexp nil t))
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4663 (spec (match-beginning 0))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4664 body-file)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4665 (if found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4666 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4667 (goto-char spec)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4668 (if (and (re-search-forward "(\\|;" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4669 (= (char-before) ?\())
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4670 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4671 (ada-search-ignore-string-comment ")" nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4672 (ada-search-ignore-string-comment ";" nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4673 (set 'spec (buffer-substring spec (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4674
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4675 ;; If find-file.el was available, use its functions
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4676 (set 'body-file (ada-get-body-name))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4677 (if body-file
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4678 (find-file body-file)
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4679 (error "No body found for the package. Create it first."))
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4680
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4681 (save-restriction
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4682 (widen)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4683 (goto-char (point-max))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4684 (forward-comment -10000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4685 (re-search-backward "\\<end\\>" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4686 ;; Move to the beginning of the elaboration part, if any
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4687 (re-search-backward "^begin" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4688 (newline)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4689 (forward-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4690 (insert spec)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4691 (re-search-backward ada-procedure-start-regexp nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4692 (ada-gen-treat-proc (cons (match-beginning 0) (match-end 0)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4693 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4694 (error "Not in subprogram spec"))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4695
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4696 ;; --------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4697 ;; Global initializations
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4698 ;; --------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4699
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4700 ;; Create the keymap once and for all. If we do that in ada-mode,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4701 ;; the keys changed in the user's .emacs have to be modified
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4702 ;; every time
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4703 (ada-create-keymap)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4704 (ada-create-menu)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4705
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4706 ;; Create the syntax tables, but do not activate them
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4707 (ada-create-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4708
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4709 ;; Add the default extensions (and set up speedbar)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4710 (ada-add-extensions ".ads" ".adb")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4711 ;; This two files are generated by GNAT when running with -gnatD
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4712 (if (equal ada-which-compiler 'gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4713 (ada-add-extensions ".ads.dg" ".adb.dg"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4714
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4715 ;; Read the special cases for exceptions
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4716 (ada-case-read-exceptions)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4717
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4718 ;; include the other ada-mode files
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4719 (if (equal ada-which-compiler 'gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4720 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4721 ;; The order here is important: ada-xref defines the Project
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4722 ;; submenu, and ada-prj adds to it.
30411
41f228350eca Got rid of all byte-compiler warnings on Emacs Load
Gerd Moellmann <gerd@gnu.org>
parents: 28995
diff changeset
4723 (require 'ada-xref)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4724 (condition-case nil (require 'ada-prj) (error nil))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4725 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4726 (condition-case nil (require 'ada-stmt) (error nil))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4727
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4728 ;;; provide ourselves
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4729 (provide 'ada-mode)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4730
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
4731 ;;; ada-mode.el ends here