annotate lisp/progmodes/ada-mode.el @ 27660:c3cdb8d6d50d

*** empty log message ***
author Dave Love <fx@gnu.org>
date Thu, 10 Feb 2000 20:28:26 +0000
parents 91cb7b3bae3c
children 93c16141d107
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1 ;; @(#) ada-mode.el --- major-mode for editing Ada sources.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3 ;; Copyright (C) 1994, 1995, 1997, 1998, 1999 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>
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
9 ;; Ada Core Technologies's version: $Revision: 1.70 $
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.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
30 ;;; This is a major rewrite of the file packaged with Emacs-20.2. 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:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
98 ;;; Note: Every function is this package is compiler-independent.
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)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
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)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
113 (not (or is-xemacs xemacs-running)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
114 (or (> emacs-major-version major)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
115 (and (= emacs-major-version major)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
116 (>= emacs-minor-version minor)))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
117
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
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
120 ;; This should not be evaluated at compile time, only a runtime
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
121 (defconst ada-xemacs (boundp 'running-xemacs)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
122 "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
123
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
124 (unless ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
125 (require 'outline))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
126
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
127 (eval-and-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
128 (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
129
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
130 ;; 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
131 ;; 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
132 ;; (require 'ada-support)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
133
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
134 (defvar ada-mode-hook nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
135 "*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
136 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
137 fully loaded.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
138 This is a good place to add Ada environment specific bindings.")
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
139
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
140 (defgroup ada nil
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
141 "Major mode for editing Ada source in Emacs."
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
142 :group 'languages)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
143
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
144 (defcustom ada-auto-case t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
145 "*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
146 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
147 and `ada-case-attribute'."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
148 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
149
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
150 (defcustom ada-broken-decl-indent 0
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
151 "*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
152
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
153 An example is :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
154 declare
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
155 A,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
156 >>>>>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
157 :type 'integer :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
158
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
159 (defcustom ada-broken-indent 2
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
160 "*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
161
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
162 An example is :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
163 My_Var : My_Type := (Field1 =>
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
164 >>>>>>>>>Value); -- from ada-broken-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
165 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
166
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
167 (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
168 "*Function to call to adjust the case of Ada attributes.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
169 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
170 `ada-capitalize-word'."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
171 :type '(choice (const downcase-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
172 (const upcase-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
173 (const ada-capitalize-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
174 (const ada-loose-case-word))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
175 :group 'ada)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
177 (defcustom ada-case-exception-file "~/.emacs_case_exceptions"
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
178 "*File name for the dictionary of special casing exceptions for identifiers.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
179 This file should contain one word per line, that gives the casing
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
180 to be used for that words in Ada files."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
181 :type 'file :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
182
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
183 (defcustom ada-case-keyword 'downcase-word
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
184 "*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
185 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
186 `ada-capitalize-word'."
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
187 :type '(choice (const downcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
188 (const upcase-word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
189 (const ada-capitalize-word)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
190 (const ada-loose-case-word))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
191 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
192
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
193 (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
194 "*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
195 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
196 `ada-capitalize-word'."
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
197 :type '(choice (const downcase-word)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
198 (const upcase-word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
199 (const ada-capitalize-word)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
200 (const ada-loose-case-word))
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
201 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
202
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
203 (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
204 "*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
205 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
206
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
207 (defcustom ada-indent 3
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
208 "*Size of Ada indentation.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
209
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
210 An example is :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
211 procedure Foo is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
212 begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
213 >>>>>>>>>>null; -- from ada-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
214 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
215
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
216 (defcustom ada-indent-after-return t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
217 "*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
218 :type 'boolean :group 'ada)
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 (defcustom ada-indent-comment-as-code t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
221 "*Non-nil means indent comment lines as code."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
222 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
223
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
224 (defcustom ada-indent-is-separate t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
225 "*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
226 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
227
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
228 (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
229 "*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
230
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
231 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
232 type A is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
233 >>>>>>>>>>>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
234 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
235
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
236 (defcustom ada-indent-return 0
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
237 "*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
238 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
239 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
240
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
241 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
242 function A (B : Integer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
243 >>>>>return C; -- from ada-indent-return"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
244 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
245
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
246 (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
247 "*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
248 :type 'boolean :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
249
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
250 (defcustom ada-fill-comment-prefix "-- "
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
251 "*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
252 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
253 reread this variable."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
254 :type 'string :group 'ada)
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
255
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
256 (defcustom ada-fill-comment-postfix " --"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
257 "*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
258 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
259 :type 'string :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
260
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
261 (defcustom ada-label-indent -4
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
262 "*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
263
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
264 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
265 procedure Foo is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
266 begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
267 >>>>>>>>>>>>Label: -- from ada-label-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
268 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
269
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
270 (defcustom ada-language-version 'ada95
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
271 "*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
272 :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
273
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
274 (defcustom ada-move-to-declaration nil
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
275 "*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
276 not to 'begin'."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
277 :type 'boolean :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
278
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
279 (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
280 "*Key used for binding the contextual menu.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
281 If nil, no contextual menu is available.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
282
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
283 (defcustom ada-search-directories
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
284 '("." "$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
285 "/opt/gnu/adainclude")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
286 "*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
287 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
288 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
289 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
290 runtime really is."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
291 :type '(repeat (choice :tag "Directory"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
292 (const :tag "default" nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
293 (directory :format "%v")))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
294 :group 'ada)
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
295
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
296 (defcustom ada-stmt-end-indent 0
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
297 "*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
298
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
299 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
300 if A = B
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
301 >>>>>>>>>>>then -- from ada-stmt-end-indent"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
302 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
303
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
304 (defcustom ada-tab-policy 'indent-auto
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
305 "*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
306 Must be one of :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
307 `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
308 `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
309 `always-tab' : do indent-relative."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
310 :type '(choice (const indent-auto)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
311 (const indent-rigidly)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
312 (const always-tab))
18120
112bc3055da6 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17996
diff changeset
313 :group 'ada)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
315 (defcustom ada-when-indent 3
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
316 "*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
317
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
318 An example is:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
319 case A is
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
320 >>>>>>>>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
321 :type 'integer :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
322
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
323 (defcustom ada-which-compiler 'gnat
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
324 "*Name of the compiler to use.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
325 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
326 The possible choices are :
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
327 `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
328 features
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
329 `generic': Use a generic compiler"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
330 :type '(choice (const gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
331 (const generic))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
332 :group 'ada)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
333
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
334
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 ;;; ---- end of user configurable variables
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
338 (defvar ada-body-suffixes '(".adb")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
339 "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
340 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
341
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
342 (defvar ada-spec-suffixes '(".ads")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
343 "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
344 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
345
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
346 (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
347 "Menu for ada-mode.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
348
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
349 (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
350 "Local keymap used for Ada mode.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (defvar ada-mode-syntax-table nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 "Syntax table to be used for editing Ada source code.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
355 (defvar ada-mode-symbol-syntax-table nil
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
356 "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
357
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
358 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
359 (defconst ada-83-string-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
360 '("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
361 "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
362 "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
363 "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
364 "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
365 "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
366 "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
367 "type" "use" "when" "while" "with" "xor")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
368 "List of Ada keywords.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
369 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
370
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
371 (defvar ada-ret-binding nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
372 "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
373
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
374 (defvar ada-case-exception '()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
375 "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
376
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
377 (defvar ada-lfd-binding nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
378 "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
379
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
380 (defvar ada-other-file-alist nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
381 "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
382 See `ff-other-file-alist'.")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
383
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
384 ;;; ---- 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
385
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (defconst ada-83-keywords
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
387 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
388 (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
389 "Regular expression for looking at Ada83 keywords.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
391 (defconst ada-95-keywords
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
392 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
393 (concat "\\<" (regexp-opt
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
394 (append
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
395 '("abstract" "aliased" "protected" "requeue"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
396 "tagged" "until")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
397 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
398 "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
399
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
400 (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
401 "Regular expression for looking at Ada keywords.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
403 (defconst ada-ident-re
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
404 "\\(\\sw\\|[_.]\\)+"
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
405 "Regexp matching Ada (qualified) identifiers.")
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
406
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (defvar ada-procedure-start-regexp
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
408 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\(\\(\\sw\\|[_.]\\)+\\)"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 "Regexp used to find Ada procedures/functions.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (defvar ada-package-start-regexp
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 "^[ \t]*\\(package\\)"
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
413 "Regexp used to find Ada packages.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 ;;; ---- regexps for indentation functions
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (defvar ada-block-start-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
419 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
420 (concat "\\<\\(" (regexp-opt '("begin" "declare" "else"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
421 "exception" "generic" "loop" "or"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
422 "private" "select" ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
423 "\\|\\(\\(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
424 "Regexp for keywords starting Ada blocks.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (defvar ada-end-stmt-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
427 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
428 (concat "\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
429 ";" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
430 "=>[ \t]*$" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
431 "^[ \t]*separate[ \t]*(\\(\\sw\\|[_.]\\)+)" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
432 "\\<" (regexp-opt '("begin" "declare" "is" "do" "else" "generic" "loop"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
433 "private" "record" "select" "then") t) "\\>" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
434 "^[ \t]*" (regexp-opt '("function" "package" "procedure")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
435 t) "\\>\\(\\sw\\|[ \t_.]\\)+\\<is\\>" "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
436 "^[ \t]*exception\\>"
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 "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
439 A new statement starts after these.")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
441 (defvar ada-matching-start-re
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
442 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
443 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
444 (regexp-opt
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
445 '("end" "loop" "select" "begin" "case" "do"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
446 "if" "task" "package" "record" "protected") t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
447 "\\>"))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
448 "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
449
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
450 (defvar ada-matching-decl-start-re
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
451 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
452 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
453 (regexp-opt
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
454 '("is" "separate" "end" "declare" "if" "new" "begin" "generic") t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
455 "\\>"))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
456 "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
457
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
458
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (defvar ada-loop-start-re
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 "\\<\\(for\\|while\\|loop\\)\\>"
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 "Regexp for the start of a loop.")
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-subprog-start-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
464 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
465 (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
466 "protected" "task") t) "\\>"))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 "Regexp for the start of a subprogram.")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
469 (defvar ada-named-block-re
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
470 "[ \t]*\\(\\sw\\|_\\)+[ \t]*:[^=]"
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
471 "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
472
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
473 (defvar ada-contextual-menu-on-identifier nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
474 "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
475
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
476 (defvar ada-contextual-menu
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
477 "Defines the menu to use when the user presses the right mouse button.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
478 The variable `ada-contextual-menu-on-identifier' will be set to t before
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
479 displaying the menu if point was on an identifier."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
480 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
481 '("Ada"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
482 ["Goto Declaration/Body" ada-goto-declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
483 :included ada-contextual-menu-on-identifier]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
484 ["Goto Previous Reference" ada-xref-goto-previous-reference]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
485 ["List References" ada-find-references
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
486 :included ada-contextual-menu-on-identifier]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
487 ["-" nil nil]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
488 ["Other File" ff-find-other-file]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
489 ["Goto Parent Unit" ada-goto-parent]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
490 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
491
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
492 (let ((map (make-sparse-keymap "Ada")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
493 ;; The identifier part
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
494 (if (equal ada-which-compiler 'gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
495 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
496 (define-key-after map [Ref]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
497 '(menu-item "Goto Declaration/Body"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
498 ada-point-and-xref
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
499 :visible ada-contextual-menu-on-identifier
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
500 ) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
501 (define-key-after map [Prev]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
502 '("Goto Previous Reference" .ada-xref-goto-previous-reference) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
503 (define-key-after map [List]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
504 '(menu-item "List References"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
505 ada-find-references
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
506 :visible ada-contextual-menu-on-identifier) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
507 (define-key-after map [-] '("-" nil) t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
508 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
509 (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
510 (define-key-after map [Parent] '("Goto Parent Unit" . ada-goto-parent)t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
511 map)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
512
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
513
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
514
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
515 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
516 ;; Support for imenu (see imenu.el)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
517 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
518
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
519 (defvar ada-imenu-generic-expression
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
520 (list
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
521 '(nil "^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)[ \t\n]*\\([ \t\n]\\|([^)]+)\\)[ \t\n]*\\(return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?is[ \t\n]" 2)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
522 (list "*Specs*"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
523 (concat
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
524 "^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
525 "\\("
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
526 "\\([ \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
527 "\\([ \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
528 "\\)?;") 2)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
529 '("*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
530 '("*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
531 '("*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
532 "Imenu generic expression for Ada mode.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
533 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
534 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
535 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
536
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
537
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
538 ;;------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
539 ;; Support for compile.el
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
540 ;;------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
541
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
542 (defun ada-compile-mouse-goto-error ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
543 "Mouse interface for `ada-compile-goto-error'."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
544 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
545 (mouse-set-point last-input-event)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
546 (ada-compile-goto-error (point))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
547 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
548
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
549 (defun ada-compile-goto-error (pos)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
550 "Replaces `compile-goto-error' from compile.el.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
551 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
552 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
553 For instance, on this line:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
554 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
555 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
556 (interactive "d")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
557 (goto-char pos)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
558
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
559 (skip-chars-backward "-a-zA-Z0-9_:./\\")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
560 (cond
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
561 ;; 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
562 ((and (not (bolp))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
563 (looking-at
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
564 "\\(\\(\\sw\\|[_-.]\\)+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?"))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
565 (let ((line (match-string 3))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
566 (error-pos (point-marker))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
567 source)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
568 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
569 (save-restriction
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
570 (widen)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
571 (set-buffer (compilation-find-file (point-marker) (match-string 1)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
572 "./"))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
573 (if (stringp line)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
574 (goto-line (string-to-number line)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
575 (set 'source (point-marker))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
576 (compilation-goto-locus (cons source error-pos))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
577 ))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
578
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
579 ;; otherwise, default behavior
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
580 (t
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
581 (compile-goto-error))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
582 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
583 (recenter))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
584
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
585 ;;-------------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
586 ;; Grammar related function
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
587 ;; 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
588 ;; 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
589 ;; 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
590 ;; 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
591 ;; - ' 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
592 ;; - # 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
593 ;; - " 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
594 ;; - ( 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
595 ;; 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
596 ;; 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
597 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
598 ;; 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
599 ;; 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
600 ;; 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
601 ;; `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
602 ;; 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
603 ;; `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
604 ;; `ada-initialize-properties'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
605 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
606 ;; 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
607 ;; 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
608 ;; 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
609 ;; 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
610 ;; with parse-partial-sexp.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
611 ;; 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
612 ;; better is available on XEmacs.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
613 ;;-------------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
614
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
615 (defun ada-create-syntax-table ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
616 "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
617 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
618 declares it as a word constituent."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
619 (interactive)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
620 (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
621 (set-syntax-table ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
622
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
623 ;; 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
624 ;; 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
625 ;; off the track.)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
626 (modify-syntax-entry ?% "$" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
627 (modify-syntax-entry ?\" "\"" ada-mode-syntax-table)
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 (modify-syntax-entry ?: "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
630 (modify-syntax-entry ?\; "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
631 (modify-syntax-entry ?& "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
632 (modify-syntax-entry ?\| "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
633 (modify-syntax-entry ?+ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
634 (modify-syntax-entry ?* "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
635 (modify-syntax-entry ?/ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
636 (modify-syntax-entry ?= "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
637 (modify-syntax-entry ?< "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
638 (modify-syntax-entry ?> "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
639 (modify-syntax-entry ?$ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
640 (modify-syntax-entry ?\[ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
641 (modify-syntax-entry ?\] "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
642 (modify-syntax-entry ?\{ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
643 (modify-syntax-entry ?\} "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
644 (modify-syntax-entry ?. "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
645 (modify-syntax-entry ?\\ "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
646 (modify-syntax-entry ?\' "." ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
647
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
648 ;; 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
649 (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
650
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
651 ;; 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
652 ;; setup for '#'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
653 (if ada-xemacs
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
654 (modify-syntax-entry ?# "<" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
655 (modify-syntax-entry ?# "$" ada-mode-syntax-table))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
656
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
657 ;; and \f and \n end a comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
658 (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
659 (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
660
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
661 ;; define what belongs in Ada symbols
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
662 (modify-syntax-entry ?_ "_" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
663
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
664 ;; define parentheses to match
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
665 (modify-syntax-entry ?\( "()" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
666 (modify-syntax-entry ?\) ")(" ada-mode-syntax-table)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
667
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
668 (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
669 (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
670 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
671
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
672 ;; 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
673 ;; of the section on Grammar related functions).
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
674
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
675 (if ada-xemacs
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
676 (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
677 "Handles special character constants and gnatprep statements."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
678 (let (change)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
679 (if (< to from)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
680 (let ((tmp from))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
681 (setq from to to tmp)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
682 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
683 (goto-char from)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
684 (while (re-search-forward "'\\([(\")#]\\)'" to t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
685 (set 'change (cons (list (match-beginning 1)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
686 1
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
687 (match-string 1))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
688 change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
689 (replace-match "'A'"))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
690 (goto-char from)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
691 (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
692 (set 'change (cons (list (match-beginning 1)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
693 (length (match-string 1))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
694 (match-string 1))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
695 change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
696 (replace-match (make-string (length (match-string 1)) ?@))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
697 ad-do-it
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
698 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
699 (while change
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
700 (goto-char (caar change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
701 (delete-char (cadar change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
702 (insert (caddar change))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
703 (set 'change (cdr change)))))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
704
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
705 (defun ada-deactivate-properties ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
706 "Deactivate ada-mode's properties handling.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
707 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
708 (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
709
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
710 (defun ada-initialize-properties ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
711 "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
712 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
713 as numbers instead of gnatprep comments."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
714 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
715 (save-restriction
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
716 (widen)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
717 (goto-char (point-min))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
718 (while (re-search-forward "'.'" nil t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
719 (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
720 '(syntax-table ("'" . ?\"))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
721 (goto-char (point-min))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
722 (while (re-search-forward "^[ \t]*#" nil t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
723 (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
724 '(syntax-table (11 . 10))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
725 (set-buffer-modified-p nil)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
726
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
727 ;; 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
728 ;; 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
729 ;; 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
730 (make-local-hook 'after-change-functions)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
731 (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
732 )))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
733
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
734 (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
735 "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
736 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
737 (let ((inhibit-point-motion-hooks t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
738 (eol (point)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
739 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
740 (save-match-data
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
741 (beginning-of-line)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
742 (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
743 (while (re-search-forward "'.'" eol t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
744 (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
745 '(syntax-table ("'" . ?\"))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
746 (beginning-of-line)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
747 (if (looking-at "^[ \t]*#")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
748 (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
749 '(syntax-table (11 . 10))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
750 ))))
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
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
753 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
754 ;; Contextual menus
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
755 ;; The Ada-mode comes with fully contextual menus, bound by default
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
756 ;; on the right mouse button.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
757 ;; 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
758 ;; 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
759 ;; 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
760 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
761
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
762 (defun ada-popup-menu (position)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
763 "Pops up a contextual menu, depending on where the user clicked.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
764 POSITION is the location the mouse was clicked on."
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
765 (interactive "e")
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 (mouse-set-point last-input-event)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
768
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
769 (setq ada-contextual-menu-on-identifier
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
770 (and (char-after)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
771 (or (= (char-syntax (char-after)) ?w)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
772 (= (char-after) ?_))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
773 (not (ada-in-string-or-comment-p))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
774 (save-excursion (skip-syntax-forward "w")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
775 (not (ada-after-keyword-p)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
776 ))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
777 (let (choice)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
778 (if ada-xemacs
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
779 (set 'choice (popup-menu ada-contextual-menu))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
780 (set 'choice (x-popup-menu position ada-contextual-menu)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
781 (if choice
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
782 (funcall (lookup-key ada-contextual-menu (vector (car choice))))))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
783
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
784 ;;------------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
785 ;; Misc functions
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
786 ;;------------------------------------------------------------------
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
787
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
788 ;;;###autoload
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
789 (defun ada-add-extensions (spec body)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
790 "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
791 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
792 extensions.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
793 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
794 name"
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
795 (let* ((reg (concat (regexp-quote body) "$"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
796 (tmp (assoc reg ada-other-file-alist)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
797 (if tmp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
798 (setcdr tmp (list (cons spec (cadr tmp))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
799 (add-to-list 'ada-other-file-alist (list reg (list spec)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
800
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
801 (let* ((reg (concat (regexp-quote spec) "$"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
802 (tmp (assoc reg ada-other-file-alist)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
803 (if tmp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
804 (setcdr tmp (list (cons body (cadr tmp))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
805 (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
806
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
807 (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
808 (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
809
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
810 (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
811 (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
812
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
813 ;; 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
814 ;; speedbar)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
815 (condition-case nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
816 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
817 (require 'speedbar)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
818 (speedbar-add-supported-extension spec)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
819 (speedbar-add-supported-extension body)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
820 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
821
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
822
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
824 ;;;###autoload
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (defun ada-mode ()
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
826 "Ada mode is the major mode for editing Ada code.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 Bindings are as follows: (Note: 'LFD' is control-j.)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 Indent line '\\[ada-tab]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 Indent line, insert newline and indent the new line. '\\[newline-and-indent]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 Re-format the parameter-list point is in '\\[ada-format-paramlist]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 Indent all lines in region '\\[ada-indent-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 Adjust case of identifiers and keywords in region '\\[ada-adjust-case-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 Adjust case of identifiers and keywords in buffer '\\[ada-adjust-case-buffer]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
839 Fill comment paragraph, justify and append postfix '\\[fill-paragraph]'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
841 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
842 Next package '\\[ada-next-package]' Previous package '\\[ada-previous-package]'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 Goto matching start of current 'end ...;' '\\[ada-move-to-start]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 Goto end of current block '\\[ada-move-to-end]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 Comments are handled using standard GNU Emacs conventions, including:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 Start a comment '\\[indent-for-comment]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 Comment region '\\[comment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 Uncomment region '\\[ada-uncomment-region]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 Continue comment on next line '\\[indent-new-comment-line]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 If you use imenu.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 Display index-menu of functions & procedures '\\[imenu]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 If you use find-file.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 Switch to other file (Body <-> Spec) '\\[ff-find-other-file]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 or '\\[ff-mouse-find-other-file]
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 Switch to other file in other window '\\[ada-ff-other-window]'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 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
861 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
862
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 If you use ada-xref.el:
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 Goto declaration: '\\[ada-point-and-xref]' on the identifier
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 or '\\[ada-goto-declaration]' with point on the identifier
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
866 Complete identifier: '\\[ada-complete-identifier]'"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 (kill-all-local-variables)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
871 (set (make-local-variable 'require-final-newline) t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 (make-local-variable 'comment-start)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
874 (if ada-fill-comment-prefix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
875 (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
876 (set 'comment-start "-- "))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
877
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
878 ;; 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
879 ;; simply with M-h
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
880 (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
881 (set (make-local-variable 'paragraph-separate) "[ \t\n\f]*$")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 ;; 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
884 ;; 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
885 (set (make-local-variable 'comment-end) "")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
886
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
887 ;; 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
888 (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
889
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
890 ;; 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
891 ;; 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
892 ;; 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
893 ;; 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
894 ;; 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
895 (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
896 (lambda (&optional soft) (let ((fill-prefix nil))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
897 (indent-new-comment-line soft))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
898
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
899 (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
900 'ada-indent-current-function)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
901
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
902 (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
903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
904 ;; 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
905 ;; 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
906 ;; included in comment-start
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
907 (unless ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
908 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
909 (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
910 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
911 (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
912 (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
913 (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
914 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
915
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
916 (set 'case-fold-search t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
917 (if (boundp 'imenu-case-fold-search)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
918 (set 'imenu-case-fold-search t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
919
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
920 (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
921 'ada-fill-comment-paragraph)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
922
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
923 (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
924 ada-imenu-generic-expression)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
925
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
926 ;; Support for compile.el
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
927 ;; 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
928 (add-hook 'compilation-mode-hook
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
929 '(lambda()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
930 (set 'compile-auto-highlight 40)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
931 (define-key compilation-minor-mode-map [mouse-2]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
932 'ada-compile-mouse-goto-error)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
933 (define-key compilation-minor-mode-map "\C-c\C-c"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
934 'ada-compile-goto-error)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
935 (define-key compilation-minor-mode-map "\C-m"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
936 'ada-compile-goto-error)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
937 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
938
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
939 ;; font-lock support :
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
940 ;; 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
941 ;; for Emacs
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 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
944 ;; XEmacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
945 (put 'ada-mode 'font-lock-defaults
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
946 '(ada-font-lock-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
947 nil t ((?\_ . "w") (?# . ".")) beginning-of-line))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
948 ;; Emacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
949 (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
950 '(ada-font-lock-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
951 nil t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
952 ((?\_ . "w") (?# . "."))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
953 beginning-of-line
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
954 (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
955 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
956
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
957 ;; 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
958 (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
959 'ada-other-file-alist)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
960 (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
961 'ada-search-directories)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
962 (setq ff-post-load-hooks 'ada-set-point-accordingly
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
963 ff-file-created-hooks 'ada-make-body)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
964 (add-hook 'ff-pre-load-hooks 'ada-which-function-are-we-in)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
965
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
966 ;; 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
967 ;; 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
968 ;; standard find-file.el
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
969 ;; Go to the parent package :
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
970 (make-local-variable 'ff-special-constructs)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
971 (add-to-list 'ff-special-constructs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
972 (cons (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
973 (concat "^\\(private[ \t]\\)?[ \t]*package[ \t]+"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
974 "\\(body[ \t]+\\)?"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
975 "\\(\\(\\sw\\|[_.]\\)+\\)\\.\\(\\sw\\|_\\)+[ \t\n]+is"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
976 '(lambda ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
977 (set 'fname (ff-get-file
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
978 ff-search-directories
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
979 (ada-make-filename-from-adaname
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
980 (match-string 3))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
981 ada-spec-suffixes)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
982 ;; 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
983 ;; go to the correct package.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
984 (add-to-list 'ff-special-constructs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
985 (cons "^separate[ \t\n]*(\\(\\(\\sw\\|[_.]\\)+\\))"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
986 '(lambda ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
987 (set 'fname (ff-get-file
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
988 ff-search-directories
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
989 (ada-make-filename-from-adaname
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
990 (match-string 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
991 ada-spec-suffixes)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
992 ;; 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
993 ;; old one can handle only one possible type of extension for Ada files
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
994 (add-to-list 'ff-special-constructs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
995 (cons "^with[ \t]+\\([a-zA-Z0-9_\\.]+\\)"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
996 '(lambda ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
997 (set 'fname (ff-get-file
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
998 ff-search-directories
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
999 (ada-make-filename-from-adaname
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1000 (match-string 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1001 ada-spec-suffixes)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1002
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1003 ;; Support for outline-minor-mode
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1004 (set (make-local-variable 'outline-regexp)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1005 "\\([ \t]*\\(procedure\\|function\\|package\\|with\\|use\\)\\|--\\|end\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1006 (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
1007
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1008 ;; 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
1009 (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
1010
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1011 ;; Set up the contextual menu
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1012 (if ada-popup-key
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1013 (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
1014
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1015 ;; 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
1016 (set 'comment-multi-line nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1017 (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
1018
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1019 (set 'major-mode 'ada-mode)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1020 (set 'mode-name "Ada")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (use-local-map ada-mode-map)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1024 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1025 (easy-menu-add ada-mode-menu ada-mode-map))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1026
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1027 (set-syntax-table ada-mode-syntax-table)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 (if ada-clean-buffer-before-saving
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1031 ;; 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
1032 (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
1033 ;; 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
1034 (add-hook 'local-write-file-hooks
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1035 '(lambda () (untabify (point-min) (point-max))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 (run-hooks 'ada-mode-hook)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1039 ;; 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
1040 ;; font-lock-mode
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1041
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1042 (unless ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1043 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1044 (ada-initialize-properties)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1045 (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
1046 (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
1047
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 ;; the following has to be done after running the ada-mode-hook
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 ;; because users might want to set the values of these variable
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 ;; inside the hook (MH)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1051 ;; Note that we add the new elements at the end of ada-other-file-alist
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1052 ;; since some user might want to give priority to some other extensions
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1053 ;; first (for instance, a .adb file could be associated with a .ads
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1054 ;; or a .ads.gp (gnatprep)).
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1055 ;; This is why we can't use add-to-list here.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 (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
1058 (set 'ada-keywords ada-83-keywords))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1059 ((eq ada-language-version 'ada95)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1060 (set 'ada-keywords ada-95-keywords)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 (if ada-auto-case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 (ada-activate-keys-for-case)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1066 ;;-----------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1067 ;; auto-casing
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1068 ;; 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
1069 ;; functions to auto-case identifiers, keywords, ...
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1070 ;; 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
1071 ;; `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
1072 ;; 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
1073 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1074 ;; 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
1075 ;; 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
1076 ;; one word per line. These files are stored in `ada-case-exception-file'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1077 ;;-----------------------------------------------------------------
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1078
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1079 (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
1080 "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
1081 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
1082 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
1083 The standard casing rules will no longer apply to this word."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1085 (let ((previous-syntax-table (syntax-table))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1086 (exception-list '()))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1087 (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
1088 (unless word
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1089 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1090 (skip-syntax-backward "w")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1091 (set 'word (buffer-substring-no-properties
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1092 (point) (save-excursion (forward-word 1) (point))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1093
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1094 ;; 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
1095 ;; and to keep the end-of-line comments that may exist in it.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1096 (if (file-readable-p (expand-file-name ada-case-exception-file))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1097 (let ((buffer (current-buffer)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1098 (find-file (expand-file-name ada-case-exception-file))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1099 (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
1100 (widen)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1101 (goto-char (point-min))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1102 (while (not (eobp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1103 (add-to-list 'exception-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1104 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1105 (buffer-substring-no-properties
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1106 (point) (save-excursion (forward-word 1) (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1107 (buffer-substring-no-properties
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1108 (save-excursion (forward-word 1) (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1109 (save-excursion (end-of-line) (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1110 t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1111 (forward-line 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1112 (kill-buffer nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1113 (set-buffer buffer)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1114
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1115 ;; 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
1116 ;; we simply want to replace it.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1117 (if (and (not (equal exception-list '()))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1118 (assoc-ignore-case word exception-list))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1119 (setcar (assoc-ignore-case word exception-list)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1120 word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1121 (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
1122 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1123
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1124 (if (and (not (equal ada-case-exception '()))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1125 (assoc-ignore-case word ada-case-exception))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1126 (setcar (assoc-ignore-case word ada-case-exception)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1127 word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1128 (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
1129 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1130
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1131 ;; Save the list in the file
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1132 (find-file (expand-file-name ada-case-exception-file))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1133 (erase-buffer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1134 (mapcar '(lambda (x) (insert (car x) (nth 1 x) "\n"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1135 (sort exception-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1136 (lambda(a b) (string< (car a) (car b)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1137 (save-buffer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1138 (kill-buffer nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1139 (set-syntax-table previous-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1140 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1141
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1142 (defun ada-case-read-exceptions ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1143 "Parse `ada-case-exception-file' for the dictionary of casing exceptions."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1145 (set 'ada-case-exception '())
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1146 (if (file-readable-p (expand-file-name ada-case-exception-file))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1147 (let ((buffer (current-buffer)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1148 (find-file (expand-file-name ada-case-exception-file))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1149 (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
1150 (widen)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1151 (goto-char (point-min))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1152 (while (not (eobp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1153 (add-to-list 'ada-case-exception
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1154 (cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1155 (buffer-substring-no-properties
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1156 (point) (save-excursion (forward-word 1) (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1157 t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1158 (forward-line 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1159 (kill-buffer nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1160 (set-buffer buffer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1161 )))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1162
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1163 (defun ada-adjust-case-identifier ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1164 "Adjust case of the previous identifier.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1165 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
1166 the exceptions defined in `ada-case-exception-file'."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1167 (if (or (equal ada-case-exception '())
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1168 (equal (char-after) ?_))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1169 (funcall ada-case-identifier -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1170
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1171 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1172 (let ((end (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1173 (start (save-excursion (skip-syntax-backward "w")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1174 (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1175 match)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1176 ;; 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
1177 (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
1178 ada-case-exception))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1179
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1180 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1181 (delete-region start end)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1182 (insert (car match)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1183
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1184 ;; 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
1185 (funcall ada-case-identifier -1))))))
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 (defun ada-after-keyword-p ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1188 "Returns t if cursor is after a keyword."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 (forward-word -1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1191 (and (not (and (char-before) (= (char-before) ?_)));; unless we have a _
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 (looking-at (concat ada-keywords "[^_]")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 (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
1195 "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
1196 If FORCE-IDENTIFIER is non-nil then also adjust keyword as identifier."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1197 (let ((previous-syntax-table (syntax-table)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1198 (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
1199
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1200 (forward-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1201
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1202 ;; Do nothing in some cases
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1203 (if (and (> (point) 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1204
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1205 ;; or if at the end of a character constant
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1206 (not (and (eq (char-after) ?')
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1207 (eq (char-before (1- (point))) ?')))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1208
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1209 ;; or if the previous character was not part of a word
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1210 (eq (char-syntax (char-before)) ?w)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1211
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1212 ;; if in a string or a comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1213 (not (ada-in-string-or-comment-p))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1214 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1215
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1216 (if (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1217 (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1218 (or (= (point) (point-min))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1219 (backward-char 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1220 (= (char-after) ?'))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1221 (funcall ada-case-attribute -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1222 (if (and
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1223 (not force-identifier) ; (MH)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1224 (ada-after-keyword-p))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1225 (funcall ada-case-keyword -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1226 (ada-adjust-case-identifier))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1227 (forward-char 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1228 (set-syntax-table previous-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1229 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1230 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 (defun ada-adjust-case-interactive (arg)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1233 "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
1234 ARG is the prefix the user entered with \C-u."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 (let ((lastk last-command-char))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 (cond ((or (eq lastk ?\n)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 (eq lastk ?\r))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 ;; horrible kludge
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 (insert " ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 (ada-adjust-case)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1242 ;; horrible De-kludge
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (delete-backward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 ;; some special keys and their bindings
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 ((eq lastk ?\n)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 (funcall ada-lfd-binding))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 ((eq lastk ?\r)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 (funcall ada-ret-binding))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 ((eq lastk ?\C-i) (ada-tab))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 ((self-insert-command (prefix-numeric-value arg))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 ;; if there is a keyword in front of the underscore
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 ;; then it should be part of an identifier (MH)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 (if (eq lastk ?_)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 (ada-adjust-case t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (ada-adjust-case))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 (defun ada-activate-keys-for-case ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1260 "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
1261 (interactive)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1262 ;; save original key bindings to allow swapping ret/lfd
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 ;; when casing is activated
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 ;; the 'or ...' is there to be sure that the value will not
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1265 ;; be changed again when Ada mode is called more than once (MH)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 (or ada-ret-binding
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1267 (set 'ada-ret-binding (key-binding "\C-M")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 (or ada-lfd-binding
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1269 (set 'ada-lfd-binding (key-binding "\C-j")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 ;; call case modifying function after certain keys.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271 (mapcar (function (lambda(key) (define-key
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 ada-mode-map
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 (char-to-string key)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 'ada-adjust-case-interactive)))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1275 '( ?` ?~ ?! ?_ ?@ ?# ?$ ?% ?^ ?& ?* ?( ?) ?- ?= ?+ ?[ ?{ ?] ?}
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1276 ?\\ ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?? ?/ ?\n 32 ?\r )))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 (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
1279 "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
1280 No other letter is modified.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1281 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
1282 (interactive)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 (let ((pos (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 (first t))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1285 (skip-syntax-backward "w")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 (while (or first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 (search-forward "_" pos t))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 (and first
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1289 (set 'first nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 (insert-char (upcase (following-char)) 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 (delete-char 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 (goto-char pos)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1294 (defun ada-capitalize-word (&optional arg)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1295 "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
1296 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
1297 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1298 (let ((pos (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1299 (skip-syntax-backward "w")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1300 (modify-syntax-entry ?_ "_")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1301 (capitalize-region (point) pos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1302 (goto-char pos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1303 (modify-syntax-entry ?_ "w")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (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
1306 "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
1307 Attention: This function might take very long for big regions !"
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 (keywordp nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1312 (attribp nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1313 (previous-syntax-table (syntax-table)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1314 (message "Adjusting case ...")
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1315 (unwind-protect
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1316 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1317 (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
1318 (goto-char to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1319 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1320 ;; 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
1321 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1322 (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
1323 (set 'end (match-end 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1324 (set 'attribp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1325 (and (> (point) from)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1326 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1327 (forward-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1328 (set 'attribp (looking-at "'.[^']")))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1329 (or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1330 ;; 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
1331 (ada-in-string-or-comment-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1332 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1333 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1334 ;; 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
1335 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1336 (set 'begin (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1337 (set 'keywordp (looking-at ada-keywords))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1338 (goto-char end)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1339 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1340 ;; casing according to user-option
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1341 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1342 (if attribp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1343 (funcall ada-case-attribute -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1344 (if keywordp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1345 (funcall ada-case-keyword -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1346 (ada-adjust-case-identifier)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1347 (goto-char begin))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1348 (message "Adjusting case ... Done"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1349 (set-syntax-table previous-syntax-table))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (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
1352 "Adjusts the case of all words in the whole buffer.
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 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
1354 (interactive "*")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 (ada-adjust-case-region (point-min) (point-max)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1358 ;;--------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1359 ;; Format Parameter Lists
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1360 ;; 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
1361 ;; 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
1362 ;; - 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
1363 ;; format:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1364 ;; ( (<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
1365 ;; ... )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1366 ;; This is done in `ada-scan-paramlist'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1367 ;; - Delete and recreate the parameter list in function
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1368 ;; `ada-format-paramlist'.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1369 ;; 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
1370 ;; 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
1371 ;;--------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1372
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 (defun ada-format-paramlist ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1374 "Reformats the parameter list point is in."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376 (let ((begin nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 (end nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 (delend nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1379 (paramlist nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1380 (previous-syntax-table (syntax-table)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1381 (unwind-protect
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1382 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1383 (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
1384
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1385 ;; check if really inside parameter list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1386 (or (ada-in-paramlist-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1387 (error "not in parameter list"))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1388
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1389 ;; find start of current parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1390 (ada-search-ignore-string-comment
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
1391 (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
1392 (down-list 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1393 (backward-char 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1394 (set 'begin (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1395
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1396 ;; find end of parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1397 (forward-sexp 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1398 (set 'delend (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1399 (delete-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1400
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1401 ;; find end of last parameter-declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1402 (forward-comment -1000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1403 (set 'end (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1404
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1405 ;; 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
1406 (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
1407
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1408 ;; delete the original parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1409 (delete-region begin (1- delend))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1410
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1411 ;; insert the new parameter-list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1412 (goto-char begin)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1413 (ada-insert-paramlist paramlist))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1414
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1415 ;; restore syntax-table
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1416 (set-syntax-table previous-syntax-table)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1417 )))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (defun ada-scan-paramlist (begin end)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1420 "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
1421 Returns the equivalent internal parameter list."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 (let ((paramlist (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (param (list))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (notend t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 (apos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (epos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 (semipos nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 (goto-char begin)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1431
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 ;; loop until end of last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 (while notend
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1434
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 ;; find first character of parameter-declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1437 (set 'apos (point))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 ;; 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
1440 (if (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1441 (ada-search-ignore-string-comment "[ \t\n]*;" nil end t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1442 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1443 (set 'epos (car match-cons))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1444 (set 'semipos (cdr match-cons)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1445 (set 'epos end))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 ;; read name(s) of parameter(s)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (goto-char apos)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1449 (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
1450
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1451 (set 'param (list (match-string 1)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1452 (ada-search-ignore-string-comment ":" nil epos t 'search-forward)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 ;; look for 'in'
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1455 (set 'apos (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1456 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1457 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1458 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1459 (consp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1460 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1461 "in" nil epos t 'word-search-forward)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 ;; look for 'out'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 (goto-char apos)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1465 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1466 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1467 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1468 (consp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1469 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1470 "out" nil epos t 'word-search-forward)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1472 ;; look for 'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (goto-char apos)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1474 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1475 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1476 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1477 (consp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1478 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1479 "access" nil epos t 'word-search-forward)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1481 ;; skip 'in'/'out'/'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 (goto-char apos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 (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
1484 (while (looking-at "\\<\\(in\\|out\\|access\\)\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (ada-goto-next-non-ws))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1488 ;; read type of parameter
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1489 (looking-at "\\<\\(\\sw\\|[_.']\\)+\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1490 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1491 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1492 (list (match-string 0))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 ;; 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
1495 (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
1496 (set 'param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1497 (append param
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1498 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1499 (if (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1500 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1501 ":=" nil epos t 'search-forward))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1502 (buffer-substring (car match-cons) epos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1503 nil))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1504
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 ;; 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
1506 (set 'paramlist (append paramlist (list param)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 ;; check if it was the last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (if (eq epos end)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1510 (set 'notend nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 (goto-char semipos))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1512 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (reverse paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 (defun ada-insert-paramlist (paramlist)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1516 "Inserts a formatted PARAMLIST in the buffer."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 (let ((i (length paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 (parlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 (typlen 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 (temp 0)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 (inp nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 (outp nil)
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1523 (accessp nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 (column nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 (firstcol nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 (while (not (zerop i))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1529 (set 'i (1- i))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 ;; get max length of parameter-name
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1532 (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
1533
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 ;; get max length of type-name
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1535 (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
1536
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 ;; is there any 'in' ?
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1538 (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
1539
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 ;; is there any 'out' ?
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1541 (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
1542
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1543 ;; is there any 'access' ?
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1544 (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
1545 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1546
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 ;; does paramlist already start on a separate line ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 (re-search-backward "^.\\|[^ \t]" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 (looking-at "^."))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 ;; yes => re-indent it
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1552 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1553 (ada-indent-current)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1554 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1555 (if (looking-at "\\(is\\|return\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1556 (replace-match " \\1"))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1557
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1558 ;; 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
1559 (fixup-whitespace)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1560 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1561 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1562 ((looking-at "[ \t]*\\(\n\\|;\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1563 (replace-match "\\1"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1564 ((looking-at "[ \t]*\\(is\\|return\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1565 (replace-match " \\1"))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1566 (insert " "))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (insert "(")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1569 (ada-indent-current)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1570
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1571 (set 'firstcol (current-column))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1572 (set 'i (length paramlist))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 ;; loop until last parameter
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 (while (not (zerop i))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1576 (set 'i (1- i))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1577 (set 'column firstcol)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 ;; insert parameter-name, space and colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 (insert (nth 0 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 (indent-to (+ column parlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 (insert ": ")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1583 (set 'column (current-column))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 ;; insert 'in' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 (if (nth 1 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 (insert "in ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 (or inp
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1590 accessp)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 (insert " ")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594 ;; insert 'out' or space
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 (if (nth 2 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 (insert "out ")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597 (if (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 (or outp
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1599 accessp)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 (not (nth 3 (nth i paramlist))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 (insert " ")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1603 ;; insert 'access'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 (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
1605 (insert "access "))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1607 (set 'column (current-column))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 ;; insert type-name and, if necessary, space and default-expression
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 (insert (nth 4 (nth i paramlist)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 (if (nth 5 (nth i paramlist))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 (indent-to (+ column typlen 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 (insert (nth 5 (nth i paramlist)))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 ;; 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
1617 (if (zerop i)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1618 (insert ")")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1619 ;; no => insert ';' and newline and indent
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1620 (insert ";")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1621 (newline)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1622 (indent-to firstcol))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1623 )
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1624
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1625 ;; if anything follows, except semicolon, newline, is or return
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626 ;; 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
1627 (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
1628 (ada-indent-newline-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631
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 ;;; Move To Matching Start/End ;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 ;;;----------------------------;;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 (defun ada-move-to-start ()
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
1636 "Moves point to the matching start of the current Ada structure."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1638 (let ((pos (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1639 (previous-syntax-table (syntax-table)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1640 (unwind-protect
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1641 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1642 (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
1643
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1644 (message "searching for block start ...")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1645 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1646 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1647 ;; do nothing if in string or comment or not on 'end ...;'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1648 ;; or if an error occurs during processing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1649 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1650 (or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1651 (ada-in-string-or-comment-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1652 (and (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1653 (or (looking-at "[ \t]*\\<end\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1654 (backward-word 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1655 (or (looking-at "[ \t]*\\<end\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1656 (backward-word 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1657 (or (looking-at "[ \t]*\\<end\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1658 (error "not on end ...;")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1659 (ada-goto-matching-start 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1660 (set 'pos (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1661
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1662 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1663 ;; on 'begin' => go on, according to user option
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1664 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1665 ada-move-to-declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1666 (looking-at "\\<begin\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1667 (ada-goto-matching-decl-start)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1668 (set 'pos (point))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1669
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1670 ) ; end of save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1671
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1672 ;; now really move to the found position
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1673 (goto-char pos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1674 (message "searching for block start ... done"))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1675
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1677 ;; restore syntax-table
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1678 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1679 (set-syntax-table previous-syntax-table))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 (defun ada-move-to-end ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 "Moves point to the matching end of the current block around point.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 Moves to 'begin' if in a declarative part."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1685 (let ((pos (point))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1686 (previous-syntax-table (syntax-table)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1687 (unwind-protect
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1688 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1689 (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
1690
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1691 (message "searching for block end ...")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1692 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1693
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1694 (forward-char 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1695 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1696 ;; directly on 'begin'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1697 ((save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1698 (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1699 (looking-at "\\<begin\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1700 (ada-goto-matching-end 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1701 ;; on first line of defun declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1702 ((save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1703 (and (ada-goto-stmt-start)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1704 (looking-at "\\<function\\>\\|\\<procedure\\>" )))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1705 (ada-search-ignore-string-comment "begin" nil nil nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1706 'word-search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1707 ;; on first line of task declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1708 ((save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1709 (and (ada-goto-stmt-start)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1710 (looking-at "\\<task\\>" )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1711 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1712 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1713 (looking-at "\\<body\\>")))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1714 (ada-search-ignore-string-comment "begin" nil nil nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1715 'word-search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1716 ;; accept block start
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1717 ((save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1718 (and (ada-goto-stmt-start)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1719 (looking-at "\\<accept\\>" )))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1720 (ada-goto-matching-end 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1721 ;; package start
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1722 ((save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1723 (and (ada-goto-matching-decl-start t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1724 (looking-at "\\<package\\>")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1725 (ada-goto-matching-end 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1726 ;; inside a 'begin' ... 'end' block
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1727 ((save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1728 (ada-goto-matching-decl-start t))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1729 (ada-search-ignore-string-comment "begin" nil nil nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1730 'word-search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1731 ;; (hopefully ;-) everything else
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1732 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1733 (ada-goto-matching-end 1)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1734 (set 'pos (point))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1735 )
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1736
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1737 ;; now really move to the found position
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1738 (goto-char pos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1739 (message "searching for block end ... done"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1740
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1741 ;; restore syntax-table
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1742 (set-syntax-table previous-syntax-table))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1745 ;;;----------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1746 ;; Indentation Engine
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1747 ;; 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
1748 ;; - position of reference in the buffer
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1749 ;; - 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
1750 ;; that are evaluated)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1751 ;; 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
1752 ;; 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
1753 ;; 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
1754 ;; 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
1755 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1756 ;; 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
1757 ;; 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
1758 ;; 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
1759 ;; based on previous lines.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1760 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1761 ;; The relevant functions for indentation are:
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1762 ;; - `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
1763 ;; - `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
1764 ;; calculation that were done
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1765 ;; - `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
1766 ;; - `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
1767 ;; based on the context (see above).
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1768 ;; - `ada-get-indent-*': Calculate the indentation in a specific context.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1769 ;; For efficiency, these functions do not check the correct context.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1770 ;;;----------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1771
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 (defun ada-indent-region (beg end)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1773 "Indent the region between BEG and END."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 (interactive "*r")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 (goto-char beg)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1776 (let ((block-done 0)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1777 (lines-remaining (count-lines beg end))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1778 (msg (format "indenting %4d lines %%4d lines remaining ..."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1779 (count-lines beg end)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1780 (endmark (copy-marker end)))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1781 ;; catch errors while indenting
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1782 (while (< (point) endmark)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1783 (if (> block-done 39)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1784 (progn (message msg lines-remaining)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1785 (set 'block-done 0)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1786 (if (looking-at "^$") nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1787 (ada-indent-current))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1788 (forward-line 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1789 (set 'block-done (1+ block-done))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1790 (set 'lines-remaining (1- lines-remaining)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1791 (message "indenting ... done")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (defun ada-indent-newline-indent ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 "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
1795 (interactive "*")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1796 (ada-indent-current)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1797 (newline)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1798 (ada-indent-current))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1800 (defun ada-indent-newline-indent-conditional ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1801 "Insert a newline and indent it.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1802 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
1803 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
1804 (interactive "*")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1805 (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
1806 (newline)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1807 (ada-indent-current))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1808
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1809 (defun ada-justified-indent-current ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1810 "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
1811 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1812
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1813 (let ((cur-indent (ada-indent-current)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1814
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1815 (message nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1816 (if (equal (cdr cur-indent) '(0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1817 (message "same indentation")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1818 (message (mapconcat (lambda(x)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1819 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1820 ((symbolp x)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1821 (symbol-name x))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1822 ((numberp x)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1823 (number-to-string x))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1824 ((listp x)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1825 (concat "- " (symbol-name (cadr x))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1826 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1827 (cdr cur-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1828 " + ")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1829 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1830 (goto-char (car cur-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1831 (sit-for 1))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833 (defun ada-indent-current ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1834 "Indent current line as Ada code.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1835 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
1836 offset."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1838 (let ((previous-syntax-table (syntax-table))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1839 (orgpoint (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1840 cur-indent tmp-indent
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1841 prev-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1842
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1843 (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
1844
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1845 ;; This need to be done here so that the advice is not always activated
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1846 ;; (this might interact badly with other modes)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1847 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1848 (ad-activate 'parse-partial-sexp t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1849
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1850 (unwind-protect
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1851 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1852
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1853 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1854 (set 'cur-indent
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1855 ;; Not First line in the buffer ?
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1856
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1857 (if (save-excursion (zerop (forward-line -1)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1858 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1859 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1860 (ada-get-current-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1861
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1862 ;; first line in the buffer
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1863 (list (point-min) 0))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1864
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1865 ;; Evaluate the list to get the column to indent to
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1866 ;; prev-indent contains the column to indent to
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1867 (set 'prev-indent (save-excursion (goto-char (car cur-indent))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1868 (current-column)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1869 (set 'tmp-indent (cdr cur-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1870 (while (not (null tmp-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1871 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1872 ((numberp (car tmp-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1873 (set 'prev-indent (+ prev-indent (car tmp-indent))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1874 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1875 (set 'prev-indent (+ prev-indent (eval (car tmp-indent)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1876 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1877 (set 'tmp-indent (cdr tmp-indent)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1878
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1879 ;; only re-indent if indentation is different then the current
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1880 (if (= (save-excursion (back-to-indentation) (current-column)) prev-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1881 nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1882 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1883 (delete-horizontal-space)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1884 (indent-to prev-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1885 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1886 ;; restore position of point
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1887 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1888 (goto-char orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1889 (if (< (current-column) (current-indentation))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1890 (back-to-indentation))))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1891
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
1892 ;; restore syntax-table
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1893 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1894 (ad-deactivate 'parse-partial-sexp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1895 (set-syntax-table previous-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1896 cur-indent
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
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1899 (defun ada-get-current-indent ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
1900 "Returns 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
1901 (let (column
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1902 pos
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1903 match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1904 (orgpoint (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1905 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1906 (forward-comment -10000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1907 (forward-line 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1908 (point))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1911 ;; preprocessor line (gnatprep)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1912 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1913 ((and (equal ada-which-compiler 'gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1914 (looking-at "#[ \t]*\\(if\\|else\\|elsif\\|end[ \t]*if\\)"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1915 (list (save-excursion (beginning-of-line) (point)) 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1916
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1917 ;;
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 ;; in open parenthesis, but not in parameter-list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 ada-indent-to-open-paren
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 (not (ada-in-paramlist-p))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1923 (set 'column (ada-in-open-paren-p)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924 ;; 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
1925 ;; Source_File_Record)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1927 (if (and (skip-chars-backward " \t")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1928 (= (char-before) ?\n)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1929 (not (forward-comment -10000))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1930 (= (char-before) ?>))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1931 (list column 'ada-broken-indent);; ??? Could use a different variable
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1932 (list column 0))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 ;; end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937 ((looking-at "\\<end\\>")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1938 (let ((label 0))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1939 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1940 (ada-goto-matching-start 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1941
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1942 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1943 ;; found 'loop' => skip back to 'while' or 'for'
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1944 ;; if 'loop' is not on a separate line
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1945 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1946 (if (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1947 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1948 (looking-at ".+\\<loop\\>"))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1949 (if (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1950 (and
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1951 (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1952 (ada-search-ignore-string-comment ada-loop-start-re t))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1953 (not (looking-at "\\<loop\\>"))))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1954 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1955 (goto-char (car match-cons))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1956 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1957 (beginning-of-line)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
1958 (if (looking-at ada-named-block-re)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1959 (set 'label (- ada-label-indent)))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1960
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1961 (list (+ (save-excursion (back-to-indentation) (point)) label) 0))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1962 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1963 ;; exception
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1964 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965 ((looking-at "\\<exception\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967 (ada-goto-matching-start 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1968 (list (save-excursion (back-to-indentation) (point)) 0)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 ;; when
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1972 ((looking-at "\\<when\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1973 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1974 (ada-goto-matching-start 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1975 (list (save-excursion (back-to-indentation) (point)) 'ada-when-indent)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 ;; else
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1979 ((looking-at "\\<else\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1980 (if (save-excursion (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1981 (looking-at "\\<or\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1982 (ada-indent-on-previous-lines nil orgpoint orgpoint)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1983 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 (ada-goto-matching-start 1 nil t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1985 (list (progn (back-to-indentation) (point)) 0))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 ;; elsif
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 ((looking-at "\\<elsif\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 (ada-goto-matching-start 1 nil t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1992 (list (progn (back-to-indentation) (point)) 0)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1994 ;; then
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1995 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1996 ((looking-at "\\<then\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1997 (if (save-excursion (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1998 (looking-at "\\<and\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
1999 (ada-indent-on-previous-lines nil orgpoint orgpoint)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2000 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2001 ;; Select has been added for the statement: "select ... then abort"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2002 (ada-search-ignore-string-comment "\\<\\(elsif\\|if\\|select\\)\\>" t nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2003 (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2004 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 ;; loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2006 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007 ((looking-at "\\<loop\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2008 (set 'pos (point))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010 (goto-char (match-end 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 (ada-goto-stmt-start)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2012 (if (looking-at "\\<\\(loop\\|if\\)\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2013 (ada-indent-on-previous-lines nil orgpoint orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2014 (unless (looking-at ada-loop-start-re)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2015 (ada-search-ignore-string-comment ada-loop-start-re
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2016 nil pos))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2017 (if (looking-at "\\<loop\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2018 (ada-indent-on-previous-lines nil orgpoint orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2019 (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2020 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2021 ;; begin
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2022 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023 ((looking-at "\\<begin\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2025 (if (ada-goto-matching-decl-start t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2026 (list (progn (back-to-indentation) (point)) 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2027 (ada-indent-on-previous-lines nil orgpoint orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2028 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2029 ;; is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 ((looking-at "\\<is\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2032 (if (and ada-indent-is-separate
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2033 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2034 (goto-char (match-end 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2035 (ada-goto-next-non-ws (save-excursion (end-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2036 (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2037 (looking-at "\\<abstract\\>\\|\\<separate\\>")))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2038 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 (ada-goto-stmt-start)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2040 (list (progn (back-to-indentation) (point)) 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2042 (ada-goto-stmt-start)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2043 (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2044 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045 ;; record
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2047 ((looking-at "\\<record\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2048 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2049 (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2050 "\\<\\(type\\|use\\)\\>" t nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2051 (if (looking-at "\\<use\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2052 (ada-search-ignore-string-comment "for" t nil nil 'word-search-backward))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2053 (list (progn (back-to-indentation) (point)) 'ada-indent-record-rel-type)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2054 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2055 ;; 'or' as statement-start
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2056 ;; 'private' as statement-start
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2057 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2058 ((or (ada-looking-at-semi-or)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2059 (ada-looking-at-semi-private))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2061 (ada-goto-matching-start 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2062 (list (progn (back-to-indentation) (point)) 0)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2063 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2064 ;; new/abstract/separate
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2065 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2066 ((looking-at "\\<\\(new\\|abstract\\|separate\\)\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2067 (ada-indent-on-previous-lines nil orgpoint orgpoint))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2068 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2069 ;; return
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2070 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2071 ((looking-at "\\<return\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2072 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2073 (forward-comment -1000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2074 (if (= (char-before) ?\))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2075 (forward-sexp -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2076 (forward-word -1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2077
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2078 ;; If there is a parameter list, and we have a function declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2079 (if (and (= (char-after) ?\()
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2080 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2081 (backward-sexp 2)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2082 (looking-at "\\<function\\>")))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2083
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2084 ;; The indentation depends of the value of ada-indent-return
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2085 (if (<= ada-indent-return 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2086 (list (point) (- ada-indent-return))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2087 (list (progn (backward-sexp 2) (point)) ada-indent-return))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2088
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2089 ;; Else there is no parameter list, but we have a function
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2090 ;; Only do something special if the user want to indent relative
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2091 ;; to the "function" keyword
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2092 (if (and (> ada-indent-return 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2093 (save-excursion (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2094 (looking-at "\\<function\\>")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2095 (list (progn (forward-word -1) (point)) ada-indent-return)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2096
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2097 ;; Else...
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2098 (ada-indent-on-previous-lines nil orgpoint orgpoint)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2099 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2100 ;; do
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2101 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102 ((looking-at "\\<do\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2103 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2104 (ada-goto-stmt-start)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2105 (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2107 ;; package/function/procedure
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 ((and (looking-at "\\<\\(package\\|function\\|procedure\\)\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2113 (looking-at "\\<\\(package\\|function\\|procedure\\)\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2115 ;; look for 'generic'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 (if (and (ada-goto-matching-decl-start t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 (looking-at "generic"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2118 (list (progn (back-to-indentation) (point)) 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2119 (ada-indent-on-previous-lines nil orgpoint orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 ;; label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2123 ((looking-at "\\<\\(\\sw\\|_\\)+[ \t\n]*:[^=]")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124 (if (ada-in-decl-p)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2125 (ada-indent-on-previous-lines nil orgpoint orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2126 (set 'pos (ada-indent-on-previous-lines nil orgpoint orgpoint))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2127 (list (car pos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2128 (cadr pos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2129 'ada-label-indent)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2131 ;; identifier and other noindent-statements
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2133 ((looking-at "\\<\\(\\sw\\|_\\)+[ \t\n]*")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2134 (ada-indent-on-previous-lines nil orgpoint orgpoint))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 ;; beginning of a parameter list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2137 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2138 ((and (not (eobp)) (= (char-after) ?\())
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2139 (ada-indent-on-previous-lines nil orgpoint orgpoint))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2140 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141 ;; end of a parameter list
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2143 ((and (not (eobp)) (= (char-after) ?\)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2144 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (forward-char 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146 (backward-sexp 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2147 (list (point) 0)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 ;; comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 ((looking-at "--")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 (if ada-indent-comment-as-code
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2153 ;; If previous line is a comment, indent likewise
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2154 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2155 (forward-line -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2156 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2157 (if (looking-at "[ \t]*--")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2158 (list (progn (back-to-indentation) (point)) 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2159 (ada-indent-on-previous-lines nil orgpoint orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2160 (list (save-excursion (back-to-indentation) (point)) 0)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2161 ;;
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2162 ;; unknown syntax
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2165 (ada-indent-on-previous-lines nil orgpoint orgpoint)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2166
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2167 (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
2168 "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
2169 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
2170 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
2171 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
2172 (if initial-pos
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2173 (goto-char initial-pos))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2174 (let ((oldpoint (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2175 result)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2177 ;; Is inside a parameter-list ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179 (if (ada-in-paramlist-p)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2180 (set 'result (ada-get-indent-paramlist))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2181
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2182 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2183 ;; move to beginning of current statement
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2184 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2185 (unless nomove
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2186 (ada-goto-stmt-start))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2187
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2188 (unless result
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2189 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2190 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2191 ;; no beginning found => don't change indentation
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2192 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2193 (if (and (eq oldpoint (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2194 (not nomove))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2195 (set 'result (ada-get-indent-nochange))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2196
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2197 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2198 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2199 ((and
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2200 ada-indent-to-open-paren
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2201 (ada-in-open-paren-p))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2202 (set 'result (ada-get-indent-open-paren)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2203 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2204 ((looking-at "end\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2205 (set 'result (ada-get-indent-end orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2206 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2207 ((looking-at ada-loop-start-re)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2208 (set 'result (ada-get-indent-loop orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2209 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2210 ((looking-at ada-subprog-start-re)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2211 (set 'result (ada-get-indent-subprog orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2212 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2213 ((looking-at ada-block-start-re)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2214 (set 'result (ada-get-indent-block-start orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2215 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2216 ((looking-at "\\(sub\\)?type\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2217 (set 'result (ada-get-indent-type orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2218 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2219 ((looking-at "\\(els\\)?if\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2220 (set 'result (ada-get-indent-if orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2221 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2222 ((looking-at "case\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2223 (set 'result (ada-get-indent-case orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2224 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2225 ((looking-at "when\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2226 (set 'result (ada-get-indent-when orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2227 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2228 ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2229 (set 'result (ada-get-indent-label orgpoint)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2230 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2231 ((looking-at "separate\\>")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2232 (set 'result (ada-get-indent-nochange)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2233 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2234 (set 'result (ada-get-indent-noindent orgpoint))))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2235
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2236 result))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2237
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2238 (defun ada-get-indent-open-paren ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2239 "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
2240 (list (ada-in-open-paren-p) 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2241
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2242 (defun ada-get-indent-nochange ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2243 "Return the current indentation of the previous line."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2244 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245 (forward-line -1)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2246 (back-to-indentation)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2247 (list (point) 0)))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2248
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2249 (defun ada-get-indent-paramlist ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2250 "Calculates the indentation when point is inside a parameter list."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 (ada-search-ignore-string-comment "[^ \t\n]" t nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 ;; 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
2255 ((= (char-after) ?\()
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (goto-char (match-end 0))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2257 (list (point) 0))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2258
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259 ;; in front of another parameter
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2260 ((= (char-after) ?\;)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2263 (list (point) 0))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2264
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 ;; inside a parameter declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 (t
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2269 (list (point) 'ada-broken-indent)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2270
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2271 (defun ada-get-indent-end (orgpoint)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2272 "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
2273 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 (let ((defun-name nil)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2275 (label 0)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 (indent nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 ;; is the line already terminated by ';' ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 (if (save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2281 (ada-search-ignore-string-comment ";" nil orgpoint nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2282 'search-forward))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 ;; yes, look what's following 'end'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2287 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 (cond
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2290 ((looking-at "\\<\\(loop\\|select\\|if\\|case\\)\\>")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2291 (save-excursion (ada-check-matching-start (match-string 0)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2292 (list (save-excursion (back-to-indentation) (point)) 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2293
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295 ;; loop/select/if/case/record/select
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2297 ((looking-at "\\<record\\>")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2299 (ada-check-matching-start (match-string 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2300 ;; we are now looking at the matching "record" statement
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2301 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2302 (ada-goto-stmt-start)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2303 ;; now on the matching type declaration, or use clause
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2304 (unless (looking-at "\\(for\\|type\\)\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2305 (ada-search-ignore-string-comment "\\<type\\>" t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2306 (list (progn (back-to-indentation) (point)) 0)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 ;; a named block end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2310 ((looking-at ada-ident-re)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2311 (set 'defun-name (match-string 0))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2312 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2313 (ada-goto-matching-start 0)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2314 (ada-check-defun-name defun-name))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2315 (list (progn (back-to-indentation) (point)) 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2316 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 ;; a block-end without name
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2318 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2319 ((= (char-after) ?\;)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2320 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2321 (ada-goto-matching-start 0)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2322 (if (looking-at "\\<begin\\>")
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2323 (progn
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2324 (set 'indent (list (point) 0))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2325 (if (ada-goto-matching-decl-start t)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2326 (list (progn (back-to-indentation) (point)) 0)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2327 indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2328 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 ;; anything else - should maybe signal an error ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 (t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2332 (list (save-excursion (back-to-indentation) (point))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2333 'ada-broken-indent))))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2334
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2335 (list (save-excursion (back-to-indentation) (point))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2336 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 (defun ada-get-indent-case (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2339 "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
2340 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
2341 (let ((match-cons nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 (opos (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 ;; case..is..when..=>
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2348 (set 'match-cons (and
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2349 ;; 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
2350 (ada-search-ignore-string-comment
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2351 "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
2352 (ada-search-ignore-string-comment
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2353 "[ \t\n]+=>" nil orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 (goto-char (car match-cons))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2356 (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
2357 (error "missing 'when' between 'case' and '=>'"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2358 (list (save-excursion (back-to-indentation) (point)) 'ada-indent)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360 ;; case..is..when
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2363 (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
2364 "when" nil orgpoint nil 'word-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 (goto-char (cdr match-cons))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2366 (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 ;; case..is
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2369 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2371 (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
2372 "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
2373 (list (save-excursion (back-to-indentation) (point)) 'ada-when-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375 ;; incomplete case
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2377 (t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2378 (list (save-excursion (back-to-indentation) (point))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2379 'ada-broken-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2381 (defun ada-get-indent-when (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2382 "Calcules the indentation when point is just before a when statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2383 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
2384 (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
2385 (if (ada-search-ignore-string-comment "[ \t\n]*=>" nil orgpoint)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2386 (list cur-indent 'ada-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2387 (list cur-indent 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2388
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2389 (defun ada-get-indent-if (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2390 "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
2391 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
2392 (let ((cur-indent (save-excursion (back-to-indentation) (point)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2393 (match-cons nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2394 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2395 ;; Move to the correct then (ignore all "and then")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2396 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2397 (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
2398 "\\<\\(then\\|and[ \t]*then\\)\\>"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2399 nil orgpoint))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2400 (= (char-after (car match-cons)) ?a)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2401 ;; 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
2402 (if match-cons
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2404 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2405 ;; 'then' first in separate line ?
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2406 ;; => indent according to 'then',
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2407 ;; => else indent according to 'if'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2408 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411 (looking-at "\\<then\\>"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2412 (set '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
2413 ;; skip 'then'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 (forward-word 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2415 (list cur-indent 'ada-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2416
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2417 (list cur-indent 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2418
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2419 (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
2420 "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
2421 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
2422 (let ((pos nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2423 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425 (forward-word 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2426 (set 'pos (ada-goto-next-non-ws orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 (goto-char pos)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2429 (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
2430
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 ;; nothing follows the block-start
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2433 (list (save-excursion (back-to-indentation) (point)) 'ada-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2434
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 (defun ada-get-indent-subprog (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2436 "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
2437 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438 (let ((match-cons nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2439 (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
2440 (foundis nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442 ;; is there an 'is' in front of point ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2443 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2444 (if (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2445 (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2446 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2447 "\\<\\(is\\|do\\)\\>" nil orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2448 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 ;; yes, then skip to its end
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2451 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2452 (set 'foundis t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 (goto-char (cdr match-cons)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2454 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2455 ;; 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
2456 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2458 (unless (ada-goto-next-non-ws orgpoint)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 (goto-char orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 ;; nothing follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2468 (not (ada-search-ignore-string-comment
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2469 "[^ \t\n]" nil orgpoint t))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2470 (list cur-indent 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2471 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472 ;; is abstract/separate/new ...
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475 foundis
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2477 (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2478 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2479 "\\<\\(separate\\|new\\|abstract\\)\\>"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2480 nil orgpoint))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 (goto-char (car match-cons))
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
2482 (ada-search-ignore-string-comment ada-subprog-start-re t)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 (ada-get-indent-noindent orgpoint))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2485 ;; something follows 'is'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 foundis
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2489 (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
2490 (goto-char match-cons)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2491 (ada-indent-on-previous-lines t orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 ;; no 'is' but ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2495 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2496 (ada-search-ignore-string-comment ";" nil orgpoint nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2497 'search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2498 (list cur-indent 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 ;; no 'is' or ';'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2503 (list cur-indent 'ada-broken-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 (defun ada-get-indent-noindent (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2506 "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
2507 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
2508 (let ((label 0))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2509 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2510 (beginning-of-line)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2511
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2512 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2513
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2514 ;; This one is called when indenting a line preceded by a multiline
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2515 ;; 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
2516 ;; the parameter declaration list)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2517 ((ada-in-paramlist-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2518 (ada-previous-procedure)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2519 (list (save-excursion (back-to-indentation) (point)) 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2520
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2521 ;; 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
2522 ;; 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
2523 ((looking-at "[ \t]*\\(\\sw\\|_\\)*[ \t]*,[ \t]*$")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2524 (list (save-excursion (back-to-indentation) (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2525 'ada-broken-decl-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2526
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2527 ;; 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
2528 ;; top level
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2529 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2530 (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
2531 (set 'label (- ada-label-indent))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2532
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2533 ;; "with private" or "null record" cases
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2534 (if (or (and (re-search-forward "\\<private\\>" orgpoint t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2535 (save-excursion (forward-char -7);; skip back "private"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2536 (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2537 (looking-at "with")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2538 (and (re-search-forward "\\<record\\>" orgpoint t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2539 (save-excursion (forward-char -6);; skip back "record"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2540 (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2541 (looking-at "null"))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2542 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2543 (re-search-backward "\\<\\(type\\|subtype\\)\\>" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2544 (list (save-excursion (back-to-indentation) (point)) 0))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2545 (if (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2546 (ada-search-ignore-string-comment ";" nil orgpoint nil 'search-forward))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2547 (list (+ (save-excursion (back-to-indentation) (point)) label) 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2548 (list (+ (save-excursion (back-to-indentation) (point)) label)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2549 'ada-broken-indent)))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (defun ada-get-indent-label (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2552 "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
2553 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2554 (let ((match-cons nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2555 (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
2556 (ada-search-ignore-string-comment ":" nil)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2558 ;; loop label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2559 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2560 (set 'match-cons (ada-search-ignore-string-comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2561 ada-loop-start-re nil orgpoint)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2563 (ada-get-indent-loop orgpoint))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2564
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 ;; declare label
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2567 (set 'match-cons (ada-search-ignore-string-comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2568 "\\<declare\\|begin\\>" nil orgpoint)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2569 (goto-char (car match-cons))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2570 (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
2571
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2572 ;; variable declaration
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2573 ((ada-in-decl-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2574 (if (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2575 (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
2576 (list cur-indent 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2577 (list cur-indent 'ada-broken-indent)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2578
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 ;; nothing follows colon
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2581 (list cur-indent '(- ada-label-indent))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583 (defun ada-get-indent-loop (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2584 "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
2585 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 (let ((match-cons nil)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2587 (pos (point))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2588
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2589 ;; 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
2590 (label (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2591 (beginning-of-line)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2592 (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
2593 (- ada-label-indent)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2594 0))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2595
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2597
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2599 ;; statement complete
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2600 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2601 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2602 (ada-search-ignore-string-comment ";" nil orgpoint nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2603 'search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2604 (list (+ (save-excursion (back-to-indentation) (point)) label) 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2605 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2606 ;; simple loop
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 ((looking-at "loop\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2609 (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
2610 (if (equal label 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2611 pos
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2612 (list (+ (car pos) label) (cdr pos))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 ;; 'for'- loop (or also a for ... use statement)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2617 ((looking-at "for\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2619 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2620 ;; for ... use
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2621 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2622 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 (goto-char (match-end 0))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2625 (ada-goto-next-non-ws orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2626 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2627 (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
2628 (ada-goto-next-non-ws orgpoint)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2629 (looking-at "\\<use\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2631 ;; check if there is a 'record' before point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2634 (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
2635 "record" nil orgpoint nil 'word-search-forward))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2636 t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637 (if match-cons
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 (goto-char (car match-cons)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2639 (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641 ;; for..loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2642 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2644 (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
2645 "loop" nil orgpoint nil 'word-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2648 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2649 ;; otherwise to 'for'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2651 (unless (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2652 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2653 (looking-at "\\<loop\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2654 (goto-char pos))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2655 (list (+ (save-excursion (back-to-indentation) (point)) label)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2656 'ada-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2658 ;; for-statement is broken
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2659 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 (t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2661 (list (+ (save-excursion (back-to-indentation) (point)) label)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2662 'ada-broken-indent))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2664 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2665 ;; 'while'-loop
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2666 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2667 ((looking-at "while\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2668 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2669 ;; while..loop ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2670 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2671 (if (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2672 (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
2673 "loop" nil orgpoint nil 'word-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2674
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2675 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2676 (goto-char (car match-cons))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2677 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678 ;; indent according to 'loop', if it's first in the line;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2679 ;; otherwise to 'while'.
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2680 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2681 (unless (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2682 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2683 (looking-at "\\<loop\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2684 (goto-char pos))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2685 (list (+ (save-excursion (back-to-indentation) (point)) label)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2686 'ada-indent))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2687
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2688 (list (+ (save-excursion (back-to-indentation) (point)) label)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2689 'ada-broken-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
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 (defun ada-get-indent-type (orgpoint)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2693 "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
2694 ORGPOINT is the limit position used in the calculation."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695 (let ((match-dat nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2696 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2697 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2698 ;; complete record declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2699 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700 ((save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2701 (and
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2702 (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
2703 "end" nil orgpoint nil 'word-search-forward))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2705 (looking-at "\\<record\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2706 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2707 (ada-goto-next-non-ws)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2708 (= (char-after) ?\;)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2709 (goto-char (car match-dat))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2710 (list (save-excursion (back-to-indentation) (point)) 0))
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 ;; record type
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
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2715 (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
2716 "record" nil orgpoint nil 'word-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2717 (goto-char (car match-dat))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2718 (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
10705
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 ;; complete type declaration
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2721 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2722 ((save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2723 (ada-search-ignore-string-comment ";" nil orgpoint nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2724 'search-forward))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2725 (list (save-excursion (back-to-indentation) (point)) 0))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2726 ;;
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
2727 ;; "type ... is", but not "type ... is ...", which is broken
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2728 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2729 ((save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2730 (and
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2731 (ada-search-ignore-string-comment "is" nil orgpoint nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2732 'word-search-forward)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2733 (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
2734 (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2735 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2736 ;; broken statement
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2737 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2738 (t
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2739 (list (save-excursion (back-to-indentation) (point))
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2740 'ada-broken-indent)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2741
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2742
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2743 ;; -----------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2744 ;; -- searching and matching
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2745 ;; -----------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2746
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2747 (defun ada-goto-stmt-start ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2748 "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
2749 Returns the new position of point.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2750 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
2751 open parenthesis."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2752 (let ((match-dat nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2753 (orgpoint (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2755 (set 'match-dat (ada-search-prev-end-stmt))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2756 (if match-dat
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2757
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2758 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2759 ;; found a previous end-statement => check if anything follows
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2760 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2761 (unless (looking-at "declare")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2762 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2763 (unless (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2764 (goto-char (cdr match-dat))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2765 (ada-goto-next-non-ws orgpoint))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767 ;; nothing follows => it's the end-statement directly in
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2768 ;; front of point => search again
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2769 ;;
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2770 (set 'match-dat (ada-search-prev-end-stmt)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2771 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2772 ;; if found the correct end-statement => goto next non-ws
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2773 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2774 (if match-dat
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2775 (goto-char (cdr match-dat)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2776 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2777 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2778
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 ;; no previous end-statement => we are at the beginning of the
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2781 ;; accessible part of the buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2782 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2784 (goto-char (point-min))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2785 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2786 ;; skip to the very first statement, if there is one
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2787 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2788 (unless (ada-goto-next-non-ws orgpoint)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2789 (goto-char orgpoint))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2790
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791 (point)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2794 (defun ada-search-prev-end-stmt ()
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2795 "Moves point to previous end-statement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2796 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
2797 match."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2798 (let ((match-dat nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2799 (found nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2800 parse)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2801
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2802 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2803 ;; search until found or beginning-of-buffer
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2804 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2805 (while
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2806 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2807 (not found)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2808 (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
2809 ada-end-stmt-re t)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2810
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2811 (goto-char (car match-dat))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2812 (unless (ada-in-open-paren-p)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2813 (if (and (looking-at
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2814 "\\<\\(record\\|loop\\|select\\|else\\|then\\)\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2815 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2816 (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2817 (looking-at "\\<\\(end\\|or\\|and\\)\\>[ \t]*[^;]")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2818 (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2819
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2820 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2821 (goto-char (cdr match-dat))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2822 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2823 (looking-at "(")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2824 ;; 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
2825 (unless (looking-at
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2826 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2827 (concat "\\<"
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2828 (regexp-opt '("separate" "access" "array"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2829 "abstract" "new") t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2830 "\\>\\|(")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2831 (set 'found t))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2832 ))
10705
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 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2835 match-dat
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2837
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839 (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
2840 "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
2841 Stop the search at LIMIT.
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2842 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
2843 (unless limit
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2844 (set 'limit (point-max)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2845 (while (and (<= (point) limit)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2846 (progn (forward-comment 10000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2847 (if (and (not (eobp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2848 (save-excursion (forward-char 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2849 (ada-in-string-p)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2850 (progn (forward-sexp 1) t)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2851 (if (< (point) limit)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2852 (point)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2853 nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2854 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 (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
2858 "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
2859 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
2860 Stop the search at LIMIT."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2861 (if (ada-search-ignore-string-comment ada-end-stmt-re nil limit)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 (point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2866 (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
2867 "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
2868 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
2869 Returns the new position of point or nil if not found."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2870 (let ((match-cons nil)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2871 (orgpoint (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2872 (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
2873 (modify-syntax-entry ?_ "w")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2874 (unless backward
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2875 (skip-syntax-forward "w"));; ??? Used to have . too
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2876 (if (set 'match-cons
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2877 (if backward
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2878 (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
2879 (ada-search-ignore-string-comment "\\w" nil nil t)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 ;; move to the beginning of the word found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 (progn
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2884 (goto-char (car match-cons))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2885 (skip-syntax-backward "w")
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 ;; if not found, restore old position of point
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2890 (goto-char orgpoint)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2891 'nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2892 (modify-syntax-entry ?_ old-syntax))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2893 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2894
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2895
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2896 (defsubst ada-goto-previous-word ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2897 "Moves point to the beginning of the previous word of Ada code.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2898 Returns the new position of point or nil if not found."
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2899 (ada-goto-next-word t))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2900
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2901
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 (defun ada-check-matching-start (keyword)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2903 "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
2904 Moves point to the matching block start."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 (ada-goto-matching-start 0)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2906 (unless (looking-at (concat "\\<" keyword "\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2907 (error "matching start is not '%s'" keyword)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2908
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2909
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2910 (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
2911 "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
2912 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
2913 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
2914
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2915 ;; named block without a `declare'
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2916 (if (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2917 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2918 (looking-at (concat "\\<" defun-name "\\> *:")))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2919 t ; do nothing
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2921 ;; 'accept' or 'package' ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2922 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2923 (unless (looking-at "\\<\\(accept\\|package\\|task\\|protected\\)\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2924 (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
2925 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2926 ;; '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
2927 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2928 (save-excursion
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2930 ;; a named 'declare'-block ?
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2932 (if (looking-at "\\<declare\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2933 (ada-goto-stmt-start)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2935 ;; no, => 'procedure'/'function'/'task'/'protected'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 ;;
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2937 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2938 (forward-word 2)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2939 (backward-word 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2940 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2941 ;; skip 'body' 'type'
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2942 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2943 (if (looking-at "\\<\\(body\\|type\\)\\>")
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2944 (forward-word 1))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2945 (forward-sexp 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2946 (backward-sexp 1)))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2947 ;;
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
2948 ;; 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
2949 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2950 (unless (looking-at (concat "\\<" defun-name "\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2951 (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
2952 (buffer-substring (point)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2953 (progn (forward-sexp 1) (point))))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2955 (defun ada-goto-matching-decl-start (&optional noerror)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2956 "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
2957 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
2958 (let ((nest-count 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959 (first t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2960 (flag nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2961 (count-generic nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2962 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2963
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2964 (if (or
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2965 (looking-at "\\<\\(package\\|procedure\\|function\\)\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2966 (save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2967 (ada-search-ignore-string-comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
2968 "\\<\\(package\\|procedure\\|function\\|generic\\)\\>" t)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2969 (looking-at "generic")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2970 (set 'count-generic t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2971
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974 (not (zerop nest-count))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2975 (ada-search-ignore-string-comment ada-matching-decl-start-re t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2980 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981 ((looking-at "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2982 (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
2983
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2984 ;; In some case, two begin..end block can follow each other closely,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2985 ;; which we have to detect, as in
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2986 ;; procedure P is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2987 ;; procedure Q is
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2988 ;; begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2989 ;; end;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2990 ;; begin -- here we should go to procedure, not begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2991 ;; end
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2992
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2993 (let ((loop-again 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2994 (if (looking-at "begin")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2995 (set 'loop-again 1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2996
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2997 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2998 (while (not (= loop-again 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
2999
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3000 ;; If begin was just there as the beginning of a block (with no
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3001 ;; declare) then do nothing, otherwise just register that we
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3002 ;; have to find the statement that required the begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3003
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3004 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3005 "declare\\|begin\\|end\\|procedure\\|function\\|task\\|package"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3006 t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3007
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3008 (if (looking-at "end")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3009 (set 'loop-again (1+ loop-again))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3010
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3011 (set 'loop-again (1- loop-again))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3012 (unless (looking-at "begin")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3013 (set 'nest-count (1+ nest-count))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3014 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3015 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3017 ((looking-at "generic")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3018 (if count-generic
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3019 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3020 (set 'first nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3021 (set 'nest-count (1- nest-count)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3022 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3023 ((looking-at "declare\\|generic\\|if")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3024 (set 'nest-count (1- nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3025 (set 'first nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3027 ((looking-at "is")
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3028 ;; 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
3029 ;; 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
3030 (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
3031 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3032 (forward-comment -10000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3033 (forward-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3034
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3035 ;; 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
3036 ;; 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
3037 ;; in a type definition
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3038 (if (= (char-after) ?\))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3039 (progn
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3040 (forward-char 1)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3041 (backward-sexp 1)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3042 (forward-comment -10000)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3043 ))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3044 (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
3045 (ada-goto-previous-word)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3046 (and
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3047 (looking-at "\\<\\(sub\\)?type\\>")
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3048 (save-match-data
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3049 (ada-goto-previous-word)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3050 (not (looking-at "\\<protected\\>"))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3051 )) ; end of `or'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3052 (goto-char (match-beginning 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3053 (progn
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3054 (set 'nest-count (1- nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3055 (set 'first nil))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 ((looking-at "new")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 (if (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 (ada-goto-previous-word)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061 (looking-at "is"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3062 (goto-char (match-beginning 0))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3063 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3064 ((and first
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3065 (looking-at "begin"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3066 (set 'nest-count 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3067 (set 'flag t))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3068 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3069 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3070 (set 'nest-count (1+ nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3071 (set 'first nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3072
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3073 );; end of loop
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3074
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3075 ;; 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
3076 (if (and
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3077 (zerop nest-count)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3078 (not flag)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3079 (if (looking-at "is")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3080 (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
3081 (looking-at "declare\\|generic")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3082 t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3083 (if noerror nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3084 (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
3085 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3086
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3087 (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
3088 "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
3089 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
3090 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
3091 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
3092 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3093 (found nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3094 (pos nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3095
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097 ;; search backward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3098 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3099 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3100 (not found)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3101 (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
3102
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3103 (unless (and (looking-at "\\<record\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3104 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3105 (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3106 (looking-at "\\<null\\>")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3107 (progn
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3109 ;; calculate nest-depth
10705
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 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3112 ;; found block end => increase nest depth
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3113 ((looking-at "end")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3114 (set 'nest-count (1+ nest-count)))
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 ;; 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
3117 ;; ends a block
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3118 ((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
3119 (set 'pos (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3120 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3121 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3122 ;; check if keyword follows 'end'
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3123 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3124 (ada-goto-previous-word)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3125 (if (looking-at "\\<end\\>[ \t]*[^;]")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3126 ;; 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
3127 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3128 (set 'nest-count (1+ nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3129 (set 'pos (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3130 ;; 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
3131 (set 'nest-count (1- nest-count))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3132 (goto-char pos))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3133
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3134 ;; 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
3135 ((looking-at "package")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3136 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3137 ;; 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
3138 (let ((current (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3139 (pos (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3140 "\\<\\(is\\|renames\\|;\\)\\>" nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3141 (if pos
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3142 (goto-char (car pos))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3143 (error (concat
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3144 "No matching 'is' or 'renames' for 'package' at"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3145 " line "
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3146 (number-to-string (count-lines (point-min)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3147 (1+ current)))))))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3148 (unless (looking-at "renames")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3149 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3150 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3151 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3152 ;; 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
3153 (if (not (looking-at "\\<\\(new\\|separate\\)\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3154 (set 'nest-count (1- nest-count)))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3155 ;; 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
3156 ((looking-at "task")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3157 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3158 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3159 (ada-goto-next-non-ws)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3160 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3161 ((looking-at "\\<body\\>"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3162 ((looking-at "\\<type\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3163 ;; 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
3164 (forward-word 2);; skip "type"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3165 (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
3166
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3167 ;; Do nothing if we are simply looking at a simple
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3168 ;; "task type name;" statement with no block
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3169 (unless (looking-at ";")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3170 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3171 ;; Skip the parameters
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3172 (if (looking-at "(")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3173 (ada-search-ignore-string-comment ")" nil))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3174 (let ((tmp (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3175 "\\<\\(is\\|;\\)\\>" nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3176 (if tmp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3177 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3178 (goto-char (car tmp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3179 (if (looking-at "is")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3180 (set 'nest-count (1- nest-count)))))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3181 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3182 ;; Check if that task declaration had a block attached to
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3183 ;; it (i.e do nothing if we have just "task name;")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3184 (unless (progn (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3185 (looking-at "[ \t]*;"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3186 (set 'nest-count (1- nest-count)))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3187 ;; all the other block starts
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3188 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3189 (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
3190
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3191 ;; 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
3192 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3193 (set 'found (zerop nest-count))))) ; end of loop
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3194
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 ;; match found => is there anything else to do ?
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 (cond
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 ;; found 'if' => skip to 'then', if it's on a separate line
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 ;; and GOTOTHEN is non-nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 ((and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 gotothen
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3207 (looking-at "if")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208 (save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3209 (ada-search-ignore-string-comment "then" nil nil nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3210 'word-search-forward)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3211 (back-to-indentation)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3212 (looking-at "\\<then\\>")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3213 (goto-char (match-beginning 0)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3214 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3215 ;; found 'do' => skip back to 'accept'
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3216 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3217 ((looking-at "do")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3218 (unless (ada-search-ignore-string-comment "accept" t nil nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3219 'word-search-backward)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3220 (error "missing 'accept' in front of 'do'"))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221 (point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3223 (if noerror
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 nil
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3225 (error "no matching start")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3226
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3227
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3228 (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
3229 "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
3230 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
3231 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
3232 (let ((nest-count (if nest-level nest-level 0))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3233 (found nil))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236 ;; search forward for interesting keywords
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 (while (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 (not found)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 (ada-search-ignore-string-comment
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3241 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3242 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3243 (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
3244 "if" "task" "package" "record" "do") t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3245 "\\>")) nil))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3248 ;; calculate nest-depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (backward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3251 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3252 ;; found block end => decrease nest depth
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3253 ((looking-at "\\<end\\>")
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))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3255 ;; skip the following keyword
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3256 (if (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257 (skip-chars-forward "end")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3258 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259 (looking-at "\\<\\(loop\\|select\\|record\\|case\\|if\\)\\>"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3260 (forward-word 1)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3261 ;; found package start => check if it really starts a block
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3262 ((looking-at "\\<package\\>")
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3263 (ada-search-ignore-string-comment "is" nil nil nil
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3264 'word-search-forward)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3265 (ada-goto-next-non-ws)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266 ;; 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
3267 (if (looking-at "\\<new\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3268 (goto-char (match-end 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3269 (set 'nest-count (1+ nest-count))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270 ;; all the other block starts
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3271 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3272 (set 'nest-count (1+ nest-count))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3273 (forward-word 1))) ; end of 'cond'
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3274
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3275 ;; match is found, if nest-depth is zero
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3277 (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
3278
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3279 (if found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3280 t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3281 (if noerror
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3282 nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3283 (error "no matching end")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3284 ))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3285
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3286
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3287 (defun ada-search-ignore-string-comment
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3288 (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
3289 "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
3290 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
3291 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
3292 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
3293 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
3294 we are searching for a constant string.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3295 The search stops at pos LIMIT.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3296 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
3297 (let (found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3298 begin
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3299 end
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3300 parse-result
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3301 (previous-syntax-table (syntax-table)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3302
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3303 (unless search-func
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3304 (set 'search-func (if backward 're-search-backward 're-search-forward)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307 ;; 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
3308 ;; 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
3309 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3310 (set-syntax-table ada-mode-symbol-syntax-table)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 (while (and (not found)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3312 (or (not limit)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3313 (or (and backward (<= limit (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3314 (>= limit (point))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 (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
3316 (set 'begin (match-beginning 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3317 (set 'end (match-end 0))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3318
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3319 (set 'parse-result (parse-partial-sexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3320 (save-excursion (beginning-of-line) (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3321 (point)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3322
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3323 (cond
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3324 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3325 ;; If inside a string, skip it (and the following comments)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3326 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3327 ((ada-in-string-p parse-result)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3328 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3329 (search-backward "\"" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3330 (goto-char (nth 8 parse-result)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3331 (unless backward (forward-sexp 1)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3333 ;; 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
3334 ;; 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
3335 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3336 ((ada-in-comment-p parse-result)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3337 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3338 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3339 (forward-line 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3340 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3341 (forward-comment -1))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3342 (goto-char (nth 8 parse-result)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3343 (unless backward
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3344 ;; 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
3345 ;; 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
3346 (if (forward-comment 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3347 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3348 (forward-comment 1000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3349 (beginning-of-line))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3350 (end-of-line))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3352 ;; directly in front of a comment => skip it, if searching forward
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3354 ((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
3355 (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
3356
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3358 ;; found a parameter-list but should ignore it => skip it
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359 ;;
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3360 ((and (not paramlists) (ada-in-paramlist-p))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3361 (if backward
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3362 (search-backward "(" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3363 (search-forward ")" nil t)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3364 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 ;; found what we were looking for
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366 ;;
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3368 (set 'found t)))) ; end of loop
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3369
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3370 (set-syntax-table previous-syntax-table)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3371
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 (if found
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 (cons begin end)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3374 nil)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3375
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3376 ;; -------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3377 ;; -- Testing the position of the cursor
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3378 ;; -------------------------------------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3380 (defun ada-in-decl-p ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3381 "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
3382 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
3383 (or (ada-in-paramlist-p)
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3384 (save-excursion
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3385 (ada-goto-matching-decl-start t))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3386
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3387
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3388 (defun ada-looking-at-semi-or ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3389 "Returns t if looking-at an 'or' following a semicolon."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3390 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3391 (and (looking-at "\\<or\\>")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3392 (progn
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3393 (forward-word 1)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3394 (ada-goto-stmt-start)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3395 (looking-at "\\<or\\>")))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3396
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3397
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3398 (defun ada-looking-at-semi-private ()
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3399 "Returns t if looking-at an 'private' following a semicolon.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3400 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
3401 'private package A is...' (this can only happen at top level)."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3402 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3403 (and (looking-at "\\<private\\>")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3404 (not (looking-at "\\<private[ \t]*\\(package\\|generic\\)"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3405 (progn (forward-comment -1000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3406 (= (char-before) ?\;)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3407
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3408 (defsubst ada-in-comment-p (&optional parse-result)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3409 "Returns t if inside a comment."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3410 (nth 4 (or parse-result
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3411 (parse-partial-sexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3412 (save-excursion (beginning-of-line) (point)) (point)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3413
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3414 (defsubst ada-in-string-p (&optional parse-result)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3415 "Returns t if point is inside a string.
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3416 If parse-result is non-nil, use is instead of calling parse-partial-sexp."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3417 (nth 3 (or parse-result
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3418 (parse-partial-sexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3419 (save-excursion (beginning-of-line) (point)) (point)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3420
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3421 (defsubst ada-in-string-or-comment-p (&optional parse-result)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3422 "Returns t if inside a comment or string."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3423 (set 'parse-result (or parse-result
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3424 (parse-partial-sexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3425 (save-excursion (beginning-of-line) (point)) (point))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3426 (or (ada-in-string-p parse-result) (ada-in-comment-p parse-result)))
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 (defun ada-in-paramlist-p ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3429 "Returns t if point is inside a parameter-list."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3431 (and
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432 (re-search-backward "(\\|)" nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 ;; inside parentheses ?
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3434 (= (char-after) ?\()
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435 (backward-word 2)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3436
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3437 ;; 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
3438 ;; comment (for instance, when we have:
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3439 ;; -- .... package
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3440 ;; Test (A)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3441 ;; we should return nil
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3442
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3443 (not (ada-in-string-or-comment-p))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3444
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3445 ;; right keyword two words before parenthesis ?
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3446 ;; 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
3447 (looking-at (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3448 (concat "\\<\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3449 "procedure\\|function\\|body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3450 "task\\|entry\\|accept\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3451 "access[ \t]+procedure\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3452 "access[ \t]+function\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3453 "pragma\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3454 "type\\)\\>"))))))
10705
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 (defun ada-in-open-paren-p ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3457 "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
3458 parenthesis, or nil."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3459 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3460 (let ((parse (parse-partial-sexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3461 (point)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3462 (or (car (ada-search-ignore-string-comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3463 "\\<\\(;\\|is\\|then\\|loop\\|begin\\|else\\)\\>"
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3464 t))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3465 (point-min)))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3466
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3467 (if (nth 1 parse)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3468 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3469 (goto-char (1+ (nth 1 parse)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3470 (skip-chars-forward " \t")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3471 (point))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3473
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3474 ;;;-----------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3475 ;;; Behavior Of TAB Key
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3476 ;;;-----------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3477
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3478 (defun ada-tab ()
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3479 "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
3480 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
3481 of the region. Otherwise, operates only on the current line."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3482 (interactive)
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3483 (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
3484 ((eq ada-tab-policy 'indent-auto)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3485 ;; transient-mark-mode and mark-active are not defined in XEmacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3486 (if (or (and ada-xemacs (region-active-p))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3487 (and (not ada-xemacs)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3488 transient-mark-mode
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3489 mark-active))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3490 (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
3491 (ada-indent-current)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495 (defun ada-untab (arg)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3496 "Delete leading indenting according to `ada-tab-policy'."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497 (interactive "P")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3499 ((eq ada-tab-policy 'indent-auto) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3500 ((eq ada-tab-policy 'always-tab) (error "not implemented"))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3501 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3502
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3503 (defun ada-indent-current-function ()
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3504 "Ada mode version of the indent-line-function."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505 (interactive "*")
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506 (let ((starting-point (point-marker)))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3507 (beginning-of-line)
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 (ada-tab)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3509 (if (< (point) starting-point)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3510 (goto-char starting-point))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3511 (set-marker starting-point nil)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3512 ))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3513
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3514 (defun ada-tab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3515 "Indent current line to next tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3516 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3517 (save-excursion
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3518 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3519 (insert-char ? ada-indent))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520 (if (save-excursion (= (point) (progn (beginning-of-line) (point))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3521 (forward-char ada-indent)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3522
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3523 (defun ada-untab-hard ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3524 "indent current line to previous tab stop."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3525 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3526 (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
3527 (eol (save-excursion (progn (end-of-line) (point)))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 (indent-rigidly bol eol (- 0 ada-indent))))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3530
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3531
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3532 ;; ------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3533 ;; -- Miscellaneous
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3534 ;; ------------------------------------------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536 (defun ada-remove-trailing-spaces ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3537 "Remove trailing spaces in the whole buffer."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538 (interactive)
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3539 (save-match-data
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3540 (save-excursion
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3541 (save-restriction
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3542 (widen)
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3543 (goto-char (point-min))
12586
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3544 (while (re-search-forward "[ \t]+$" (point-max) t)
f8bbc7a3b87a (ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12053
diff changeset
3545 (replace-match "" nil nil))))))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3546
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (defun ada-ff-other-window ()
13231
fb78cec8e440 All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents: 13160
diff changeset
3548 "Find other file in other window using `ff-find-other-file'."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3549 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3550 (and (fboundp 'ff-find-other-file)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551 (ff-find-other-file t)))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3553 (defun ada-gnat-style ()
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3554 "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
3555 (interactive)
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3556 (save-excursion
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3557 (goto-char (point-min))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3558 (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
3559 (replace-match "-- \\1"))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3560 (goto-char (point-min))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3561 (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
3562 (replace-match " ("))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3563 (goto-char (point-min))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3564 (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
3565 (replace-match ", "))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3566 ))
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3567
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3568
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3569
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3570 ;; -------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3571 ;; -- Moving To Procedures/Packages
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3572 ;; -------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3573
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574 (defun ada-next-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575 "Moves point to next procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3576 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3577 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3578 (if (re-search-forward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3579 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3580 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3581
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3582 (defun ada-previous-procedure ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3583 "Moves point to previous procedure."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3584 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3585 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3586 (if (re-search-backward ada-procedure-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3587 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3588 (error "No more functions/procedures/tasks")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3589
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3590 (defun ada-next-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3591 "Moves point to next package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3593 (end-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3594 (if (re-search-forward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3595 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3596 (error "No more packages")))
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 (defun ada-previous-package ()
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599 "Moves point to previous package."
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600 (interactive)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601 (beginning-of-line)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 (if (re-search-backward ada-package-start-regexp nil t)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3603 (goto-char (match-beginning 1))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604 (error "No more packages")))
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3607 ;; ------------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3608 ;; -- Define keymap and menus for Ada
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3609 ;; -------------------------------------------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3610
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3611 (defun ada-create-keymap ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3612 "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
3613
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3614 ;; Indentation and Formatting
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3615 (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
3616 (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
3617 (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
3618 (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
3619 (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
3620 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3621 (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
3622 (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
3623 (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
3624 ;; 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
3625
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3626 ;; Movement
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3627 (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
3628 (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
3629 (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
3630 (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
3631
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3632 ;; Compilation
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3633 (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
3634 (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
3635
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3636 ;; Casing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3637 (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
3638 (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
3639 (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
3640
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3641 (define-key ada-mode-map "\177" 'backward-delete-char-untabify)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3642
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3643 ;; Make body
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3644 (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
3645
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3646 ;; 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
3647 (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
3648 (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
3649 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3650
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3651
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3652 (defun ada-create-menu ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3653 "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
3654 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
3655 can add its own items."
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3656
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3657 ;; 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
3658 (autoload 'easy-menu-define "easymenu")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3659 (autoload 'imenu "imenu")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3660 (easy-menu-define
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3661 ada-mode-menu ada-mode-map "Menu keymap for Ada mode"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3662 '("Ada"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3663 ("Help"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3664 ["Ada Mode" (info "ada-mode") t])
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3665 ["Customize" (customize-group 'ada) (>= emacs-major-version 20)]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3666 ("Goto"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3667 ["Next compilation error" next-error t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3668 ["Previous Package" ada-previous-package t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3669 ["Next Package" ada-next-package t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3670 ["Previous Procedure" ada-previous-procedure t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3671 ["Next Procedure" ada-next-procedure t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3672 ["Goto Start Of Statement" ada-move-to-start t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3673 ["Goto End Of Statement" ada-move-to-end t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3674 ["-" nil nil]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3675 ["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
3676 ["Other File Other Window" ada-ff-other-window t])
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3677 ("Edit"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3678 ["Indent Line" ada-indent-current-function t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3679 ["Justify Current Indentation" ada-justified-indent-current t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3680 ["Indent Lines in Selection" ada-indent-region t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3681 ["Indent Lines in File" (ada-indent-region (point-min) (point-max)) t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3682 ["Format Parameter List" ada-format-paramlist t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3683 ["-" nil nil]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3684 ["Comment Selection" comment-region t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3685 ["Uncomment Selection" ada-uncomment-region t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3686 ["--" nil nil]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3687 ["Fill Comment Paragraph" fill-paragraph t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3688 ["Fill Comment Paragraph Justify" ada-fill-comment-paragraph-justify t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3689 ["Fill Comment Paragraph Postfix" ada-fill-comment-paragraph-postfix t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3690 ["---" nil nil]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3691 ["Adjust Case Selection" ada-adjust-case-region t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3692 ["Adjust Case Buffer" ada-adjust-case-buffer t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3693 ["Create Case Exception" ada-create-case-exception t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3694 ["Reload Case Exceptions" ada-case-read-exceptions t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3695 ["----" nil nil]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3696 ["Make body for subprogram" ada-make-subprogram-body t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3697 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3698 ["Index" imenu t]
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3699 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3700
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3701 (if ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3702 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3703 (easy-menu-add ada-mode-menu ada-mode-map)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3704 (define-key ada-mode-map [menu-bar] ada-mode-menu)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3705 (set 'mode-popup-menu (cons "Ada mode" ada-mode-menu))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3706 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3707 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3708 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3711 ;; -------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3712 ;; Commenting/Uncommenting code
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3713 ;; The two following calls are provided to enhance the standard
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3714 ;; 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
3715 ;; 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
3716 ;; 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
3717 ;;
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3718 ;; 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
3719 ;; function for justifying the comments.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3720 ;; -------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3721
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3722 (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
3723 (if (and arg
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3724 (< arg 0)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3725 (string= mode-name "Ada"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3726 (save-excursion
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3727 (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
3728 (goto-char beg)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3729 (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
3730 (replace-match comment-start))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3731 ))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3732
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3733 (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
3734 "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
3735 (interactive "r\nP")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3736 (ad-activate 'comment-region)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3737 (comment-region beg end (- (or arg 1)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3738 (ad-deactivate 'comment-region))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3739
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3740 (defun ada-fill-comment-paragraph-justify ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3741 "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
3742 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3743 (ada-fill-comment-paragraph 'full))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3744
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3745 (defun ada-fill-comment-paragraph-postfix ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3746 "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
3747 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
3748 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3749 (ada-fill-comment-paragraph 'full t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3750
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3751 (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
3752 "Fills the current comment paragraph.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3753 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
3754 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
3755 to each filled and justified line.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3756 The paragraph is indented on the first line."
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757 (interactive "P")
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3758
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3759 ;; 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
3760 (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
3761 (not (looking-at "[ \t]*--")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3762 (error "not inside comment"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3763
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3764 (let* ((indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3765 (from)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3766 (to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3767 (opos (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3768
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3769 ;; Sets this variable to nil, otherwise it prevents
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3770 ;; fill-region-as-paragraph to work on Emacs <= 20.2
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3771 (parse-sexp-lookup-properties nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3772
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3773 fill-prefix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3774 (fill-column (current-fill-column)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3775
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3776 ;; Find end of paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3777 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3778 (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
3779 (forward-line 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3780 (back-to-indentation))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3781 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3782 (set 'to (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3783 (goto-char opos)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3784
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3785 ;; Find beginning of paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3786 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3787 (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
3788 (forward-line -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3789 (back-to-indentation))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3790 (forward-line 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3791 (beginning-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3792 (set 'from (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3793
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3794 ;; 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
3795 (back-to-indentation)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3796 (set 'indent (current-column))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3797 ;; 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
3798 (delete-region from (point))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3799
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3800 ;; Remove the old postfixes
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3801 (goto-char from)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3802 (while (re-search-forward (concat ada-fill-comment-postfix "\n") to t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3803 (replace-match "\n"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3804
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3805 (goto-char (1- to))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3806 (set 'to (point-marker))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3807
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3808 ;; Indent and justify the paragraph
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3809 (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
3810 (set-left-margin from to indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3811 (if postfix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3812 (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
3813
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3814 (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
3815
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3816 ;; Add the postfixes if required
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3817 (if postfix
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3818 (save-restriction
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3819 (goto-char from)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3820 (narrow-to-region from to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3821 (while (not (eobp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3822 (end-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3823 (insert-char ? (- fill-column (current-column)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3824 (insert ada-fill-comment-postfix)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3825 (forward-line))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3826 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3827
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3828 ;; 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
3829 ;; inserted at the end. Delete it
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3830 (if (or ada-xemacs
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3831 (<= emacs-major-version 19)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3832 (and (= emacs-major-version 20)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3833 (<= emacs-minor-version 2)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3834 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3835 (goto-char to)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3836 (end-of-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3837 (delete-char 1)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3838
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3839 (goto-char opos)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3841 ;; ---------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3842 ;; support for find-file.el
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3843 ;; 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
3844 ;; 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
3845 ;; file (body or spec).
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3846 ;; 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
3847 ;; cursor at the correct position.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3848 ;; 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
3849 ;; 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
3850 ;; 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
3851 ;; GNAT.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3852 ;; ---------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3853
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3854 ;; Overriden when we work with GNAT, to use gnatkrunch
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3855 (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
3856 "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
3857 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
3858 (while (string-match "\\." adaname)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3859 (set 'adaname (replace-match "-" t t adaname)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3860 adaname
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3861 )
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3862
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3863 (defun ada-other-file-name ()
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3864 "Return the name of the other file (the body if current-buffer is the spec,
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3865 or the spec otherwise."
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3866 (let ((ff-always-try-to-create nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3867 (buffer (current-buffer))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3868 name)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3869 (ff-find-other-file nil t) ;; same window, ignore 'with' lines
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3870
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3871 ;; If the other file was not found, return an empty string
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3872 (if (equal buffer (current-buffer))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3873 ""
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3874 (set 'name (buffer-file-name))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3875 (switch-to-buffer buffer)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3876 name)))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3877
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3878 (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
3879 "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
3880 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
3881 (set 'ff-function-name nil)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3882 (save-excursion
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3883 (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
3884 (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
3885 (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
3886 (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
3887 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3888
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3889 (defun ada-set-point-accordingly ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3890 "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
3891 `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
3892 (if ff-function-name
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3893 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3894 (goto-char (point-min))
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3895 (unless (ada-search-ignore-string-comment
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3896 (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
3897 (goto-char (point-min))))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
3898
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3899
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3900 ;; ---------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3901 ;; 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
3902 ;; 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
3903 ;; 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
3904 ;; 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
3905 ;; 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
3906 ;; 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
3907 ;;
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3908 ;; 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
3909 ;; 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
3910 ;; ----------------------------------------------------
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3911
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3912 (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
3913 ;; 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
3914 ;; 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
3915 ;; 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
3916 ;; a string
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3917 ;; 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
3918 ;; correctly handles '"' too...
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3919 '(("\\('\\)[^'\n]\\('\\)" (1 (7 . ?')) (2 (7 . ?')))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3920 ("^[ \t]*\\(#\\(if\\|else\\|elsif\\|end\\)\\)" (1 (11 . ?\n)))
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3921 ))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3922
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3923 (defvar ada-font-lock-keywords
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3924 (eval-when-compile
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3925 (list
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3926 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3927 ;; 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
3928 (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
3929
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3930 ;; preprocessor line
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3931 (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
3932
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3933 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3934 ;; 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
3935 ;; pragma, procedure, task (body) plus name.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3936 (list (concat
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3937 "\\<\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3938 "accept\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3939 "entry\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3940 "function\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3941 "package[ \t]+body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3942 "package\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3943 "pragma\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3944 "procedure\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3945 "protected[ \t]+body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3946 "protected[ \t]+type\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3947 "protected\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3948 "task[ \t]+body\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3949 "task[ \t]+type\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3950 "task"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3951 "\\)\\>[ \t]*"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3952 "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3953 '(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
3954 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3955 ;; 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
3956 (list (concat ; ":[ \t]*"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3957 "\\<\\(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
3958 "[ \t]*"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3959 "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3960 '(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
3961
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3962 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3963 ;; 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
3964 (concat "\\<"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3965 (regexp-opt
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3966 '("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
3967 "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
3968 "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
3969 "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
3970 "null" "or" "others" "private" "protected" "raise"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3971 "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
3972 "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
3973 "when" "while" "xor") t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3974 "\\>")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3975 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3976 ;; 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
3977 '("\\<\\(end\\)\\>\\([ \t]+\\)?\\(\\(\\sw\\|[_.]\\)+\\)?"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3978 (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
3979 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3980 ;; 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
3981 (list (concat "\\<\\("
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3982 "new\\|of\\|subtype\\|type"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3983 "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?[ \t]*\\((\\)?")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3984 '(1 font-lock-keyword-face)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3985 '(2 (if (match-beginning 4)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3986 font-lock-function-name-face
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3987 font-lock-type-face) nil t))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3988 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3989 ;; 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
3990 (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
3991 "[ \t\n]*\\(\\(\\sw\\|[_.|, \t\n]\\)+\\)\\W")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3992 '(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
3993 ;;
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3994 ;; Goto tags.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3995 '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
3996 ))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
3997 "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
3998
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
3999 ;; ---------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4000 ;; Support for outline.el
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4001 ;; ---------------------------------------------------------
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4002
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4003 (defun ada-outline-level ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4004 "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
4005 ;; 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
4006 (let (buffer-invisibility-spec)
25556de3fe49 (ada-outline-level): Bind buffer-invisibility-spec.
Dave Love <fx@gnu.org>
parents: 24325
diff changeset
4007 (save-excursion
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4008 (back-to-indentation)
24446
25556de3fe49 (ada-outline-level): Bind buffer-invisibility-spec.
Dave Love <fx@gnu.org>
parents: 24325
diff changeset
4009 (current-column))))
17914
e5e2ef0dd5ab (ada-krunch-args): Use gnatkr instead of gnatk8.
Richard M. Stallman <rms@gnu.org>
parents: 14415
diff changeset
4010
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4011 ;; ---------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4012 ;; Automatic generation of code
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4013 ;; 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
4014 ;; or package body from its spec.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4015 ;; 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
4016 ;; lot of improvement.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4017 ;; 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
4018 ;; body.
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4019 ;; ----------------------------------------------------------
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4020
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4021 (defun ada-gen-treat-proc (match)
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4022 "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
4023 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
4024 for ada-procedure-start-regexp."
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4025 (goto-char (car match))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4026 (let (func-found procname functype)
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4027 (cond
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4028 ((or (looking-at "^[ \t]*procedure")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4029 (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
4030 ;; treat it as a proc/func
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4031 (forward-word 2)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4032 (forward-word -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4033 (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
4034
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4035 ;; goto end of procname
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4036 (goto-char (cdr match))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4037
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4038 ;; skip over parameterlist
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4039 (unless (looking-at "[ \t\n]*\\(;\\|return\\)")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4040 (forward-sexp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4041
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4042 ;; 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
4043 (if func-found
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4044 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4045 (forward-word 1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4046 (skip-chars-forward " \t\n")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4047 (set 'functype (buffer-substring (point)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4048 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4049 (skip-chars-forward
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4050 "a-zA-Z0-9_\.")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4051 (point))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4052 ;; look for next non WS
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4053 (cond
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4054 ((looking-at "[ \t]*;")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4055 (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
4056 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4057 (insert "is")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4058 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4059 (if func-found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4060 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4061 (insert "Result : " functype ";")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4062 (ada-indent-newline-indent)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4063 (insert "begin")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4064 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4065 (if func-found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4066 (insert "return Result;")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4067 (insert "null;"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4068 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4069 (insert "end " procname ";")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4070 (ada-indent-newline-indent)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4071 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4072 ;; else
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4073 ((looking-at "[ \t\n]*is")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4074 ;; do nothing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4075 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4076 ((looking-at "[ \t\n]*rename")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4077 ;; do nothing
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4078 )
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4079 (t
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4080 (message "unknown syntax"))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4081 (t
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4082 (if (looking-at "^[ \t]*task")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4083 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4084 (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
4085 (forward-word 2)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4086 (if (looking-at "[ \t]*;")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4087 (forward-line)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4088 (ada-move-to-end))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4089 ))))))
12039
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4090
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4091 (defun ada-make-body ()
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4092 "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
4093 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
4094 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
4095 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
4096 (interactive)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4097 (delete-region (point-min) (point-max))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4098 (insert-buffer (car (cdr (buffer-list))))
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4099 (ada-mode)
a75524689022 (initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents: 11869
diff changeset
4100
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4101 (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
4102 (if (set 'found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4103 (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
4104 (progn (goto-char (cdr found))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4105 (insert " body")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4106 )
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4107 (error "No package"))
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4108
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4109 (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
4110 (concat ada-procedure-start-regexp
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4111 "\\|"
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4112 ada-package-start-regexp))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4113
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4114 (while (set 'found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4115 (ada-search-ignore-string-comment
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4116 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
4117 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4118 (goto-char (car found))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4119 (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
4120 (progn (goto-char (cdr found))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4121 (insert " body"))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4122 (ada-gen-treat-proc found))))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4123
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4124 (defun ada-make-subprogram-body ()
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4125 "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
4126 (interactive)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4127 (let* ((found (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
4128 (spec (match-beginning 0)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4129 (if found
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4130 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4131 (goto-char spec)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4132 (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
4133 (= (char-before) ?\())
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4134 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4135 (ada-search-ignore-string-comment ")" nil)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4136 (ada-search-ignore-string-comment ";" nil)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4137 (set 'spec (buffer-substring spec (point)))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4138
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4139 ;; If find-file.el was available, use its functions
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4140 (if (functionp 'ff-get-file)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4141 (find-file (ff-get-file
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4142 ff-search-directories
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4143 (ada-make-filename-from-adaname
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4144 (file-name-nondirectory
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4145 (file-name-sans-extension (buffer-name))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4146 ada-body-suffixes))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4147 ;; Else emulate it very simply
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4148 (find-file (concat (ada-make-filename-from-adaname
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4149 (file-name-nondirectory
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4150 (file-name-sans-extension (buffer-name))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4151 ".adb")))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4152
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4153 (save-restriction
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4154 (widen)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4155 (goto-char (point-max))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4156 (forward-comment -10000)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4157 (re-search-backward "\\<end\\>" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4158 ;; 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
4159 (re-search-backward "^begin" nil t)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4160 (newline)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4161 (forward-char -1)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4162 (insert spec)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4163 (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
4164 (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
4165 ))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4166 (error "Not in subprogram spec"))))
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4167
26225
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4168 ;; --------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4169 ;; Global initializations
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4170 ;; --------------------------------------------------------
91cb7b3bae3c Changed format of years in copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 25903
diff changeset
4171
25903
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4172 ;; 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
4173 ;; 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
4174 ;; every time
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4175 (ada-create-keymap)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4176 (ada-create-menu)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4177
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4178 ;; 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
4179 (ada-create-syntax-table)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4180
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4181 ;; 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
4182 (ada-add-extensions ".ads" ".adb")
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4183 ;; 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
4184 (if (equal ada-which-compiler 'gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4185 (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
4186
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4187 ;; Read the special cases for exceptions
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4188 (ada-case-read-exceptions)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4189
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4190 ;; include the other ada-mode files
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4191
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4192 (if (equal ada-which-compiler 'gnat)
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4193 (progn
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4194 ;; 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
4195 ;; submenu, and ada-prj adds to it.
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4196 (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
4197 (require 'ada-xref)
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 (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
4200
812005e9c20e (ada-get-indent-*, ada-indent-current, ada-goto-*,
Gerd Moellmann <gerd@gnu.org>
parents: 25420
diff changeset
4201 ;;; provide ourselves
10705
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4202 (provide 'ada-mode)
3d356714b662 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4203
10707
4a2ea4f52ea0 Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 10705
diff changeset
4204 ;;; ada-mode.el ends here