annotate lisp/progmodes/ada-xref.el @ 31141:a7c55d999688

Expand the explanation about Lisp files being loaded as multibyte. Add index entries.
author Eli Zaretskii <eliz@gnu.org>
date Thu, 24 Aug 2000 08:01:48 +0000
parents e3e2c9051c5f
children 0f1f7e931493
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1 ;; @(#) ada-xref.el --for lookup and completion in Ada mode
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
3 ;; Copyright (C) 1994-1999 Free Software Foundation, Inc.
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Rolf Ebert <ebert@inf.enst.fr>
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Emmanuel Briot <briot@gnat.com>
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; Maintainer: Emmanuel Briot <briot@gnat.com>
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
9 ;; Ada Core Technologies's version: $Revision: 1.99 $
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; Keywords: languages ada xref
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; This file is not part of GNU Emacs.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; This program is free software; you can redistribute it and/or modify
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; any later version.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; This program is distributed in the hope that it will be useful,
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; GNU General Public License for more details.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;; This Package provides a set of functions to use the output of the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;;; cross reference capabilities of the GNAT Ada compiler
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;;; for lookup and completion in Ada mode.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;;;
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;;; The functions provided are the following ones :
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;; - `ada-complete-identifier': completes the current identifier as much as
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;;; possible, depending of the known identifier in the unit
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;;; - `ada-point-and-xref': moves the mouse pointer and shows the declaration
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;;; of the selected identifier (either in the same buffer or in another
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;; buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;;; - `ada-goto-declaration': shows the declaration of the selected
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;; identifier (the one under the cursor), either in the same buffer or in
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;;; another buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;;; - `ada-goto-declaration-other-frame': same as previous, but opens a new
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; frame to show the declaration
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;;; - `ada-compile-application': recompile your whole application, provided
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;;; that a project file exists in your directory
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
46 ;;; - `ada-run-application': run your application directly from Emacs
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
47 ;;; - `ada-reread-prj-file': force Emacs to read your project file again.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
48 ;;; Otherwise, this file is only read the first time Emacs needs some
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;;; informations, which are then kept in memory
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;;; - `ada-change-prj': change the prj file associated with a buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;;; - `ada-change-default-prj': change the default project file used for
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;;; every new buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;;;
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;;; If a file *.`adp' exists in the ada-file directory, then it is
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;;; read for configuration informations. It is read only the first
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;;; time a cross-reference is asked for, and is not read later.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;;; You need Emacs >= 20.2 to run this package
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; ----- Requirements -----------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 (require 'compile)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 (require 'comint)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; ------ Use variables
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (defcustom ada-xref-other-buffer t
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
67 "*If nil, always display the cross-references in the same buffer.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
68 Otherwise create either a new buffer or a new frame."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 (defcustom ada-xref-create-ali t
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
72 "*If non-nil, run gcc whenever the cross-references are not up-to-date.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
73 If nil, the cross-reference mode will never run gcc."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (defcustom ada-xref-confirm-compile nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
77 "*If non-nil, always ask for user confirmation before compiling or running
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
78 the application."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 (defcustom ada-krunch-args "0"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
82 "*Maximum number of characters for filenames created by gnatkr.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
83 Set to 0, if you don't use crunched filenames. This should be a string."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
86 (defcustom ada-prj-default-comp-opt "-gnatq"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
87 "Default compilation options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
88 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
89
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
90 (defcustom ada-prj-default-bind-opt ""
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
91 "Default binder options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
92 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
93
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
94 (defcustom ada-prj-default-link-opt ""
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
95 "Default linker options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
96 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
97
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
98 (defcustom ada-prj-default-gnatmake-opt "-g"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
99 "Default options for gnatmake."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
100 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
101
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
102 (defcustom ada-prj-default-comp-cmd
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
103 "${cross_prefix}gcc -c ${comp_opt}"
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 "*Default command to be used to compile a single file.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
105 Emacs will add the filename at the end of this command. This is the same
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
106 syntax as in the project file."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
107 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
108
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
109 (defcustom ada-prj-default-debugger "${cross_prefix}gdb"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
110 "*Default name of the debugger. We recommend either `gdb',
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
111 `gdb --emacs_gdbtk' or `ddd --tty -fullname'."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (defcustom ada-prj-default-make-cmd
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
115 (concat "${cross_prefix}gnatmake -o ${main} ${main_unit} ${gnatmake_opt} "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
116 "-cargs ${comp_opt} -bargs ${bind_opt} -largs ${link_opt}")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 "*Default command to be used to compile the application.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 This is the same syntax as in the project file."
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (defcustom ada-prj-default-project-file ""
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
122 "*Name of the project file to use for every Ada file.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
123 Emacs will not try to use the standard algorithm to find the project file if
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
124 this string is not empty."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 :type '(file :must-match t) :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (defcustom ada-gnatstub-opts "-q -I${src_dir}"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
128 "*List of the options to pass to gnatsub to generate the body of a package.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
129 This has the same syntax as in the project file (with variable substitution)."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (defcustom ada-always-ask-project nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
133 "*If nil, use default values when no project file was found.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
134 Otherwise, ask the user for the name of the project file to use."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
135 :type 'boolean :group 'ada)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 ;; ------- Nothing to be modified by the user below this
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (defvar ada-last-prj-file ""
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
139 "Name of the last project file entered by the user.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
141 (defvar ada-check-switch "-gnats"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
142 "Switch added to the command line to check the current file.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (defvar ada-project-file-extension ".adp"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
145 "The extension used for project files.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (defconst is-windows (memq system-type (quote (windows-nt)))
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
148 "True if we are running on windows NT or windows 95.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
150 (defvar ada-xref-runtime-library-specs-path '()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
151 "Directories where the specs for the standard library is found.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
152 This is used for cross-references.")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
153
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
154 (defvar ada-xref-runtime-library-ali-path '()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
155 "Directories where the ali for the standard library is found.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
156 This is used for cross-references.")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
157
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (defvar ada-xref-pos-ring '()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
159 "List of positions selected by the cross-references functions.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
160 Used to go back to these positions.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 (defconst ada-xref-pos-ring-max 16
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
163 "Number of positions kept in the list ada-xref-pos-ring.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 (defvar ada-operator-re
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
166 "\\+\\|-\\|/\\|\\*\\*\\|\\*\\|=\\|&\\|abs\\|mod\\|rem\\|and\\|not\\|or\\|xor\\|<=\\|<\\|>=\\|>"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
167 "Regexp to match for operators.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (defvar ada-xref-default-prj-file nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
170 "Name of the default prj file, per directory.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
171 Every directory is potentially associated with a default project file.
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 If it is nil, then the first prj file loaded will be the default for this
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
173 Emacs session.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
175
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
176 (defvar ada-xref-project-files '()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
177 "Associative list of project files.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
178 It has the following format:
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
179 ((project_name . value) (project_name . value) ...)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
180 As always, the values of the project file are defined through properties.")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
181
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (defvar ada-prj-prj-file nil
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
183 "Buffer local variable that specifies the name of the project file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
184 Getting the project is done by looking up the key in ada-pxref-project-file.")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
185
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
186 (defun my-local-variable-if-set-p (variable &optional buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
187 "Returns t if VARIABLE is local in BUFFER and is non-nil."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
188 (and (local-variable-p variable buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
189 (save-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
190 (set-buffer buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
191 (symbol-value variable))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
192
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
193 (defun ada-initialize-runtime-library ()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
194 "Initializes the variables for the runtime library location."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
195 (save-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
196 (set 'ada-xref-runtime-library-specs-path '())
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
197 (set 'ada-xref-runtime-library-ali-path '())
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
198 (set-buffer (get-buffer-create "*gnatls*"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
199 (widen)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
200 (erase-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
201 ;; Catch any error in the following form (i.e gnatls was not found)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
202 (condition-case nil
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
203 ;; Even if we get an error, delete the *gnatls* buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
204 (unwind-protect
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
205 (progn
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
206 (call-process "gnatls" nil t nil "-v")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
207 (goto-char (point-min))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
208
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
209 ;; Source path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
210
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
211 (search-forward "Source Search Path:")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
212 (forward-line 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
213 (while (not (looking-at "^$"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
214 (back-to-indentation)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
215 (unless (looking-at "<Current_Directory>")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
216 (add-to-list 'ada-xref-runtime-library-specs-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
217 (buffer-substring-no-properties
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
218 (point)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
219 (save-excursion (end-of-line) (point)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
220 (forward-line 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
221
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
222 ;; Object path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
223
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
224 (search-forward "Object Search Path:")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
225 (forward-line 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
226 (while (not (looking-at "^$"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
227 (back-to-indentation)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
228 (unless (looking-at "<Current_Directory>")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
229 (add-to-list 'ada-xref-runtime-library-ali-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
230 (buffer-substring-no-properties
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
231 (point)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
232 (save-excursion (end-of-line) (point)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
233 (forward-line 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
234 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
235 (kill-buffer nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
236 (error nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
237 (set 'ada-xref-runtime-library-specs-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
238 (reverse ada-xref-runtime-library-specs-path))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
239 (set 'ada-xref-runtime-library-ali-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
240 (reverse ada-xref-runtime-library-ali-path))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
241 ))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
242
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
243
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
244 (defun ada-treat-cmd-string (cmd-string)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
245 "Replace meta-sequences like ${...} in CMD-STRING with the appropriate value.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
246 The project file must have been loaded first.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
247 As a special case, ${current} is replaced with the name of the currently
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
248 edited file, minus extension but with directory."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
249
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
250 (while (string-match "\\(-[^-\$IO]*[IO]\\)?\${\\([^}]+\\)}" cmd-string)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
251 (let (value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
252 (if (string= (match-string 2 cmd-string) "current")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
253 (set 'value (file-name-sans-extension (buffer-file-name)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
254 (save-match-data
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
255 (set 'value (ada-xref-get-project-field
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
256 (intern (match-string 2 cmd-string))))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
257 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
258 ((null value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
259 (set 'cmd-string (replace-match "" t t cmd-string)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
260 ((stringp value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
261 (set 'cmd-string (replace-match value t t cmd-string)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
262 ((listp value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
263 (let ((prefix (match-string 1 cmd-string)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
264 (set 'cmd-string (replace-match
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
265 (mapconcat (lambda(x) (concat prefix x)) value " ")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
266 t t cmd-string)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
267 ))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
268 cmd-string)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
269
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
270 (defun ada-xref-set-default-prj-values (symbol ada-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
271 "Reset the properties in SYMBOL to the default values for ADA-BUFFER."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
272
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
273 (let ((file (buffer-file-name ada-buffer))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
274 plist)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
275 (save-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
276 (set-buffer ada-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
277
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
278 (set 'plist
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
279 ;; Try hard to find a default value for filename, so that the user
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
280 ;; can edit his project file even if the current buffer is not an
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
281 ;; Ada file or not even associated with a file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
282 (list 'filename (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
283 (file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
284 (ada-prj-get-prj-dir file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
285 (ada-prj-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
286 ada-prj-prj-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
287 (ada-xref-default-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
288 ada-xref-default-prj-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
289 (t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
290 (error (concat "Not editing an Ada file,"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
291 "and no default project "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
292 "file specified!"))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
293 'build_dir (file-name-as-directory (expand-file-name "."))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
294 'src_dir (list ".")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
295 'obj_dir (list ".")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
296 'casing (if (listp ada-case-exception-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
297 ada-case-exception-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
298 (list ada-case-exception-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
299 'comp_opt ada-prj-default-comp-opt
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
300 'bind_opt ada-prj-default-bind-opt
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
301 'link_opt ada-prj-default-link-opt
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
302 'gnatmake_opt ada-prj-default-gnatmake-opt
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
303 'main (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
304 (file-name-sans-extension file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
305 "")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
306 'main_unit (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
307 (file-name-nondirectory
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
308 (file-name-sans-extension file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
309 "")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
310 'cross_prefix ""
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
311 'remote_machine ""
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
312 'comp_cmd (concat "cd ${build_dir} && "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
313 ada-prj-default-comp-cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
314 'check_cmd (concat ada-prj-default-comp-cmd " "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
315 ada-check-switch)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
316 'make_cmd (concat "cd ${build_dir} && "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
317 ada-prj-default-make-cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
318 'run_cmd (concat "cd ${build_dir} && ${main}"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
319 (if is-windows ".exe"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
320 'debug_cmd (concat ada-prj-default-debugger
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
321 (if is-windows " ${main}.exe"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
322 " ${main}"))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
323 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
324 (set symbol plist)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
325
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
326 (defun ada-xref-get-project-field (field)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
327 "Extract the value of FIELD from the project file of the current buffer.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
328 The project file must have been loaded first.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
329 A default value is returned if the file was not found."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
330
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
331 (let ((file-name ada-prj-prj-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
332 file value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
333
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
334 ;; If a default project file was set, use it if no other project
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
335 ;; file was specified for the buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
336 (if (and (not file-name)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
337 ada-prj-default-project-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
338 (not (string= ada-prj-default-project-file "")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
339 (set 'file-name ada-prj-default-project-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
340
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
341 (set 'file (assoc file-name ada-xref-project-files))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
342
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
343 ;; If the file was not found, use the default values
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
344 (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
345 ;; Get the value from the file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
346 (set 'value (plist-get (cdr file) field))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
347
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
348 ;; Create a default nil file that contains the default values
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
349 (ada-xref-set-default-prj-values 'value (current-buffer))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
350 (add-to-list 'ada-xref-project-files (cons nil value))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
351 (set 'value (plist-get value field))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
352 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
353 (if (stringp value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
354 (ada-treat-cmd-string value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
355 value))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
356 )
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 ;; ----- Keybindings ------------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (defun ada-add-keymap ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
361 "Add new key bindings when using `ada-xrel.el'."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (if ada-xemacs
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (define-key ada-mode-map '(shift button3) 'ada-point-and-xref)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (define-key ada-mode-map '(control tab) 'ada-complete-identifier))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (define-key ada-mode-map [C-tab] 'ada-complete-identifier)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (define-key ada-mode-map [S-mouse-3] 'ada-point-and-xref))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (define-key ada-mode-map "\C-co" 'ff-find-other-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (define-key ada-mode-map "\C-c5\C-d" 'ada-goto-declaration-other-frame)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (define-key ada-mode-map "\C-c\C-d" 'ada-goto-declaration)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (define-key ada-mode-map "\C-c\C-s" 'ada-xref-goto-previous-reference)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (define-key ada-mode-map "\C-c\C-x" 'ada-reread-prj-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (define-key ada-mode-map "\C-c\C-c" 'ada-compile-application)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (define-key ada-mode-map "\C-cb" 'ada-buffer-list)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (define-key ada-mode-map "\C-cc" 'ada-change-prj)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (define-key ada-mode-map "\C-cd" 'ada-change-default-prj)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (define-key ada-mode-map "\C-cg" 'ada-gdb-application)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (define-key ada-mode-map "\C-cr" 'ada-run-application)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (define-key ada-mode-map "\C-c\C-o" 'ada-goto-parent)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (define-key ada-mode-map "\C-c\C-r" 'ada-find-references)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (define-key ada-mode-map "\C-c\C-v" 'ada-check-current)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 ;; ----- Menus --------------------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (defun ada-add-ada-menu ()
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
388 "Add some items to the standard Ada mode menu.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
389 The items are added to the menu called NAME, which should be the same
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
390 name as was passed to `ada-create-menu'."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (if ada-xemacs
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
393 (let* ((menu-list '("Ada"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
394 (goto-menu '("Ada" "Goto"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
395 (edit-menu '("Ada" "Edit"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
396 (help-menu '("Ada" "Help"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
397 (options-menu (list "Ada" "Options")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
398 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
399 menu-list ["Check file" ada-check-current
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
400 (string= mode-name "Ada")] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
401 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
402 menu-list ["Compile file" ada-compile-current
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
403 (string= mode-name "Ada")] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
404 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
405 menu-list ["Build" ada-compile-application t] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
406 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
407 menu-list ["Run" ada-run-application t] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
408 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
409 menu-list ["Debug" ada-gdb-application t] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
410 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
411 menu-list ["--" nil t] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
412 (funcall (symbol-function 'add-submenu)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
413 menu-list '("Project"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
414 ["Associate" ada-change-prj t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
415 ["Set Default..." ada-set-default-project-file t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
416 ["List" ada-buffer-list t])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
417 "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
418 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
419 goto-menu ["Goto Parent Unit" ada-goto-parent t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
420 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
421 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
422 goto-menu ["Goto References to any entity"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
423 ada-find-any-references t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
424 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
425 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
426 goto-menu ["List References" ada-find-references t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
427 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
428 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
429 goto-menu ["Goto Declaration Other Frame"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
430 ada-goto-declaration-other-frame t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
431 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
432 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
433 goto-menu ["Goto Declaration/Body"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
434 ada-goto-declaration t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
435 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
436 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
437 goto-menu ["Goto Previous Reference"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
438 ada-xref-goto-previous-reference t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
439 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
440 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
441 goto-menu ["--" nil t] "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
442 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
443 edit-menu ["Complete Identifier"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
444 ada-complete-identifier t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
445 "Indent Line")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
446 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
447 edit-menu ["--------" nil t] "Indent Line")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
448 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
449 help-menu ["Gnat User Guide" (info "gnat_ug")])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
450 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
451 help-menu ["Gnat Reference Manual" (info "gnat_rm")])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
452 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
453 help-menu ["Gcc Documentation" (info "gcc")])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
454 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
455 help-menu ["Gdb Documentation" (info "gdb")])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
456 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
457 help-menu ["Ada95 Reference Manual" (info "arm95")])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
458 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
459 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
460 ["Show Cross-References in Other Buffer"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
461 (setq ada-xref-other-buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
462 (not ada-xref-other-buffer))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
463 :style toggle :selected ada-xref-other-buffer])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
464 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
465 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
466 ["Automatically Recompile for Cross-References"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
467 (setq ada-xref-create-ali (not ada-xref-create-ali))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
468 :style toggle :selected ada-xref-create-ali])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
469 (funcall (symbol-function 'add-menu-button)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
470 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
471 ["Confirm Commands"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
472 (setq ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
473 (not ada-xref-confirm-compile))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
474 :style toggle :selected ada-xref-confirm-compile])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
475 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
476
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 ;; for Emacs
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
478 (let* ((menu (lookup-key ada-mode-map [menu-bar Ada]))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
479 (edit-menu (lookup-key ada-mode-map [menu-bar Ada Edit]))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
480 (help-menu (lookup-key ada-mode-map [menu-bar Ada Help]))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
481 (goto-menu (lookup-key ada-mode-map [menu-bar Ada Goto]))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
482 (options-menu (lookup-key ada-mode-map [menu-bar Ada Options])))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
484 (define-key-after menu [Check] '("Check file" . ada-check-current)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
485 'Customize)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
486 (define-key-after menu [Compile] '("Compile file" . ada-compile-current)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
487 'Check)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
488 (define-key-after menu [Build] '("Build" . ada-compile-application)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
489 'Compile)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
490 (define-key-after menu [Run] '("Run" . ada-run-application) 'Build)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
491 (define-key-after menu [Debug] '("Debug" . ada-gdb-application) 'Run)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
492 (define-key-after menu [rem] '("--" . nil) 'Debug)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
493 (define-key-after menu [Project]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
494 (cons "Project"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
495 (funcall (symbol-function 'easy-menu-create-menu)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
496 "Project"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
497 '(["Associate..." ada-change-prj t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
498 :included (string= mode-name "Ada")]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
499 ["Set Default..." ada-set-default-project-file t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
500 ["List" ada-buffer-list t])))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
501 'rem)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
503 (define-key help-menu [Gnat_ug]
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 '("Gnat User Guide" . (lambda() (interactive) (info "gnat_ug"))))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
505 (define-key help-menu [Gnat_rm]
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 '("Gnat Reference Manual" . (lambda() (interactive) (info "gnat_rm"))))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
507 (define-key help-menu [Gcc]
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 '("Gcc Documentation" . (lambda() (interactive) (info "gcc"))))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
509 (define-key help-menu [gdb]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
510 '("Gdb Documentation" . (lambda() (interactive) (info "gdb"))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
511 (define-key help-menu [gdb]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
512 '("Ada95 Reference Manual" . (lambda() (interactive) (info "arm95"))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
514 (define-key goto-menu [rem] '("----" . nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
515 (define-key goto-menu [Parent] '("Goto Parent Unit"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
516 . ada-goto-parent))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
517 (define-key goto-menu [References-any]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
518 '("Goto References to any entity" . ada-find-any-references))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
519 (define-key goto-menu [References]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
520 '("List References" . ada-find-references))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
521 (define-key goto-menu [Prev]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
522 '("Goto Previous Reference" . ada-xref-goto-previous-reference))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
523 (define-key goto-menu [Decl-other]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
524 '("Goto Declaration Other Frame" . ada-goto-declaration-other-frame))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
525 (define-key goto-menu [Decl]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
526 '("Goto Declaration/Body" . ada-goto-declaration))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
527
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
528 (define-key edit-menu [rem] '("----" . nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
529 (define-key edit-menu [Complete] '("Complete Identifier"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
530 . ada-complete-identifier))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
531
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
532 (define-key-after options-menu [xrefrecompile]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
533 '(menu-item "Automatically Recompile for Cross-References"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
534 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
535 (setq ada-xref-create-ali (not ada-xref-create-ali)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
536 :button (:toggle . ada-xref-create-ali)) t)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
537 (define-key-after options-menu [xrefconfirm]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
538 '(menu-item "Confirm Commands"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
539 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
540 (setq ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
541 (not ada-xref-confirm-compile)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
542 :button (:toggle . ada-xref-confirm-compile)) t)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
543 (define-key-after options-menu [xrefother]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
544 '(menu-item "Show Cross-References in Other Buffer"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
545 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
546 (setq ada-xref-other-buffer (not ada-xref-other-buffer)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
547 :button (:toggle . ada-xref-other-buffer)) t)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 )
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
549 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
550 )
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 ;; ----- Utilities -------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (defun ada-require-project-file ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
555 "If no project file is assigned to this buffer, load one."
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
556 (if (not (my-local-variable-if-set-p 'ada-prj-prj-file (current-buffer)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
557 (ada-reread-prj-file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
558
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (defun ada-xref-push-pos (filename position)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
560 "Push (FILENAME, POSITION) on the position ring for cross-references."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (setq ada-xref-pos-ring (cons (list position filename) ada-xref-pos-ring))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (if (> (length ada-xref-pos-ring) ada-xref-pos-ring-max)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 (setcdr (nthcdr (1- ada-xref-pos-ring-max) ada-xref-pos-ring) nil)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 (defun ada-xref-goto-previous-reference ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
566 "Go to the previous cross-reference we were on."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (if ada-xref-pos-ring
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
569 (let ((pos (car ada-xref-pos-ring)))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
570 (setq ada-xref-pos-ring (cdr ada-xref-pos-ring))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
571 (find-file (car (cdr pos)))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
572 (goto-char (car pos)))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (defun ada-convert-file-name (name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
575 "Converts from NAME to a name that can be used by the compilation commands.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
576 This is overriden on VMS to convert from VMS filenames to Unix filenames."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (defun ada-set-default-project-file (name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
580 "Set the file whose name is NAME as the default project file."
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
581 (interactive "fProject file:")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
582
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
583 ;; All the directories should use this file as the default from now on,
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
584 ;; even if they were already associated with a file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
585 (set 'ada-xref-default-prj-file nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
586
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 (set 'ada-prj-default-project-file name)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
588
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
589 ;; Make sure that all the buffers see the new project file, even if they
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
590 ;; are not Ada buffers (for instance if we want to display the current
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
591 ;; project file in the frame title).
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
592 (setq-default ada-prj-prj-file name)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
593
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
594 (ada-reread-prj-file name)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
597 ;; ------ Handling the project file -----------------------------
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 (defun ada-prj-find-prj-file (&optional no-user-question)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
600 "Find the prj file associated with the current buffer.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
601 If NO-USER-QUESTION is non-nil, use a default file if not project file was
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
602 found, and do not ask the user.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
603 If the buffer is not an Ada buffer, associate it with the default project
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
604 file. If none is set, return nil."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
606 (let (selected)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
608 ;; If we don't have an ada buffer, or the current buffer is not
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
609 ;; a real file (for instance an emerge buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
610
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
611 (if (or (not (string= mode-name "Ada"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
612 (not (buffer-file-name)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
614 ;; 1st case: not an Ada buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
615 (if (and ada-prj-default-project-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
616 (not (string= ada-prj-default-project-file "")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
617 (set 'selected ada-prj-default-project-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
618
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
619 ;; 2nd case: If the buffer already has a project file, use it
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
620 (if (my-local-variable-if-set-p 'ada-prj-prj-file (current-buffer))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
621 (set 'selected ada-prj-prj-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
622
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
623 (let* ((current-file (buffer-file-name))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
624 (first-choice (concat
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
625 (file-name-sans-extension current-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
626 ada-project-file-extension))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
627 (dir (file-name-directory current-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
628
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
629 ;; on Emacs 20.2, directory-files does not work if
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
630 ;; parse-sexp-lookup-properties is set
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
631 (parse-sexp-lookup-properties nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
632 (prj-files (directory-files
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
633 dir t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
634 (concat ".*" (regexp-quote ada-project-file-extension) "$")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
635 (choice nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
636 (default (assoc dir ada-xref-default-prj-file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
637
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
638 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
639
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
640 ;; 3rd case: a project file is already associated with the directory
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
641 (default
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
642 (set 'selected (cdr default)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
643
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
644 ;; 4th case: the user has set a default project file for every file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
645 ((and ada-prj-default-project-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
646 (not (string= ada-prj-default-project-file "")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
647 (set 'selected ada-prj-default-project-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
648
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
649 ;; 5th case: there is a project file with the same name as the Ada file,
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
650 ;; but not the same extension.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
651 ((file-exists-p first-choice)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
652 (set 'selected first-choice))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
653
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
654 ;; 6th case: only one project file was found in the current directory
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
655 ((= (length prj-files) 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
656 (set 'selected (car prj-files)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
657
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
658 ;; 7th case: if there are multiple files, ask the user
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
659 ((and (> (length prj-files) 1) (not no-user-question))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
660 (save-window-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
661 (with-output-to-temp-buffer "*choice list*"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
662 (princ "There are more than one possible project file. Which one should\n")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
663 (princ "be used ?\n\n")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
664 (princ " no. file name \n")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
665 (princ " --- ------------------------\n")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
666 (let ((counter 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
667 (while (<= counter (length prj-files))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
668 (princ (format " %2d) %s\n"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
669 counter
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
670 (nth (1- counter) prj-files)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
671 (setq counter (1+ counter))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
672 ))) ; end of with-output-to ...
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
673 (setq choice nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
674 (while (or
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
675 (not choice)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
676 (not (integerp choice))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
677 (< choice 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
678 (> choice (length prj-files)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
679 (setq choice (string-to-int
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
680 (read-from-minibuffer "Enter No. of your choice: "))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
681 (set 'selected (nth (1- choice) prj-files))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
682
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
683 ;; 8th case: no project file was found in the directory, ask a name to the
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
684 ;; user, using as a default value the last one entered by the user
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
685 ((= (length prj-files) 0)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
686 (unless (or no-user-question (not ada-always-ask-project))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
687 (setq ada-last-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
688 (read-file-name "project file:" nil ada-last-prj-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
689 (unless (string= ada-last-prj-file "")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
690 (set 'selected ada-last-prj-file))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
691 ))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
692 selected
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
693 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 (defun ada-parse-prj-file (prj-file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
697 "Reads and parses the PRJ-FILE file if it was found.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
698 The current buffer should be the ada-file buffer."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
699 (if prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
700 (let (project src_dir obj_dir casing
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
701 (ada-buffer (current-buffer)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
702 (set 'prj-file (expand-file-name prj-file))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
704 ;; Initialize the project with the default values
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
705 (ada-xref-set-default-prj-values 'project (current-buffer))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
707 ;; Do not use find-file below, since we don't want to show this
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
708 ;; buffer. If the file is open through speedbar, we can't use
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
709 ;; find-file anyway, since the speedbar frame is special and does not
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
710 ;; allow the selection of a file in it.
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
712 (set-buffer (find-file-noselect prj-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
713
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
714 (widen)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
715 (goto-char (point-min))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
716
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
717 ;; Now overrides these values with the project file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
718 (while (not (eobp))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
719 (if (looking-at "^\\([^=]+\\)=\\(.*\\)")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
720 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
721 ((string= (match-string 1) "src_dir")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
722 (add-to-list 'src_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
723 (file-name-as-directory (match-string 2))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
724 ((string= (match-string 1) "obj_dir")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
725 (add-to-list 'obj_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
726 (file-name-as-directory (match-string 2))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
727 ((string= (match-string 1) "casing")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
728 (set 'casing (cons (match-string 2) casing)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
729 ((string= (match-string 1) "build_dir")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
730 (set 'project
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
731 (plist-put project 'build_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
732 (file-name-as-directory (match-string 2)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
733 (t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
734 (set 'project (plist-put project (intern (match-string 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
735 (match-string 2))))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
736 (forward-line 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
737
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
738 (if src_dir (set 'project (plist-put project 'src_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
739 (reverse src_dir))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
740 (if obj_dir (set 'project (plist-put project 'obj_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
741 (reverse obj_dir))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
742 (if casing (set 'project (plist-put project 'casing casing)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
744 ;; Memorize the newly read project file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
745 (if (assoc prj-file ada-xref-project-files)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
746 (setcdr (assoc prj-file ada-xref-project-files) project)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
747 (add-to-list 'ada-xref-project-files (cons prj-file project)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
748
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
749 ;; Sets up the compilation-search-path so that Emacs is able to
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
750 ;; go to the source of the errors in a compilation buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
751 (setq compilation-search-path (ada-get-absolute-dir-list
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
752 (plist-get project 'src_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
753 (plist-get project 'build_dir)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
754
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
755 ;; Associate each source directory in the project file with this file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
756 (mapcar (lambda (x)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
757 (if (not (assoc (expand-file-name x)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
758 ada-xref-default-prj-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
759 (setq ada-xref-default-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
760 (cons (cons (expand-file-name x) prj-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
761 ada-xref-default-prj-file))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
762 compilation-search-path)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
763
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
764 ;; Add the directories to the search path for ff-find-other-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
765 ;; Do not add the '/' or '\' at the end
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
766 (set (make-local-variable 'ff-search-directories)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
767 (append (mapcar 'directory-file-name compilation-search-path)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
768 ada-search-directories))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
769
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
770 ;; Kill the .ali buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
771 (kill-buffer nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
772 (set-buffer ada-buffer)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
774 ;; Setup the project file for the current buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
775 (set (make-local-variable 'ada-prj-prj-file) prj-file)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
777 )
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 ))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
779
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
780
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 (defun ada-find-references (&optional pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
782 "Find all references to the entity under POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
783 Calls gnatfind to find the references."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 (interactive "")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 (unless pos
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 (set 'pos (point)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 (let* ((identlist (ada-read-identifier pos))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
790 (alifile (ada-get-ali-file-name (ada-file-of identlist)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
791 (process-environment (ada-set-environment)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793 (set-buffer (get-file-buffer (ada-file-of identlist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
795 ;; if the file is more recent than the executable
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
796 (if (or (buffer-modified-p (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 (file-newer-than-file-p (ada-file-of identlist) alifile))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798 (ada-find-any-references (ada-name-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
799 (ada-file-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
800 nil nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
801 (ada-find-any-references (ada-name-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
802 (ada-file-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
803 (ada-line-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
804 (ada-column-of identlist))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
805 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
806
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
807 (defun ada-find-any-references (entity &optional file line column)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
808 "Search for references to any entity whose name is ENTITY.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
809 ENTITY was first found the location given by FILE, LINE and COLUMN."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810 (interactive "sEntity name: ")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
811 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
812
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
813 (let* ((command (concat "gnatfind -rf " entity
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
814 (if file (concat ":" (file-name-nondirectory file)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815 (if line (concat ":" line))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816 (if column (concat ":" column)))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
817
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
818 ;; If a project file is defined, use it
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 (if (my-local-variable-if-set-p 'ada-prj-prj-file (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
820 (setq command (concat command " -p" ada-prj-prj-file)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
822 (compile-internal command "No more references" "gnatfind")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
823
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
824 ;; Hide the "Compilation" menu
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
825 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
826 (set-buffer "*gnatfind*")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
827 (local-unset-key [menu-bar compilation-menu]))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
829 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
831 (defun ada-buffer-list ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
832 "Display a buffer with all the Ada buffers and their associated project."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
833 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
835 (set-buffer (get-buffer-create "*Buffer List*"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836 (setq buffer-read-only nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 (erase-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 (setq standard-output (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839 (princ "The following line is a list showing the associations between
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840 directories and project file. It has the format : ((directory_1 . project_file1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841 (directory2 . project_file2)...)\n\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 (princ ada-xref-default-prj-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
843 (princ "\n
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 Buffer Mode Project file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845 ------ ---- ------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
846 \n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847 (let ((bl (buffer-list)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848 (while bl
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 (let* ((buffer (car bl))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 (buffer-name (buffer-name buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851 this-buffer-mode-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 this-buffer-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 (setq this-buffer-mode-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 (if (eq buffer standard-output)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 "Buffer Menu" mode-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 (if (string= this-buffer-mode-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 "Ada")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 (setq this-buffer-project-file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 (if ( my-local-variable-if-set-p 'ada-prj-prj-file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 (expand-file-name ada-prj-prj-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 ""))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 (if (string= this-buffer-mode-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 "Ada")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 (princ (format "%-19s " buffer-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 (princ (format "%-6s " this-buffer-mode-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 (princ this-buffer-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 (princ "\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 ) ;; end let*
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 (setq bl (cdr bl))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 ) ;; end while
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 );; end let
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 ) ;; end save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 (display-buffer "*Buffer List*")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 (other-window 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 (defun ada-change-prj (filename)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
883 "Set FILENAME to be the project file for current buffer."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884 (interactive "fproject file:")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 ;; make sure we are using an Ada file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 (if (not (string= mode-name "Ada"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888 (error "You must be in ada-mode to use this function"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
890 (set (make-local-variable 'ada-prj-prj-file) filename)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
891 (ada-parse-prj-file filename)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
893
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894 (defun ada-change-default-prj (filename)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
895 "Set FILENAME to be the default project file for the current directory."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896 (interactive "ffile name:")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 (let ((dir (file-name-directory (buffer-file-name)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898 (prj (expand-file-name filename)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
900 ;; Associate the directory with a project file
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
901 (if (assoc dir ada-xref-default-prj-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
902 (setcdr (assoc dir ada-xref-default-prj-file) prj)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
903 (add-to-list 'ada-xref-default-prj-file (list dir prj)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
904
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
905 ;; Reparse the project file
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
906 (ada-parse-prj-file filename)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909 ;; ----- Identlist manipulation -------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
910 ;; An identlist is a vector that is used internally to reference an identifier
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911 ;; To facilitate its use, we provide the following macros
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 (defmacro ada-make-identlist () (make-vector 8 nil))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914 (defmacro ada-name-of (identlist) (list 'aref identlist 0))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
915 (defmacro ada-line-of (identlist) (list 'aref identlist 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 (defmacro ada-column-of (identlist) (list 'aref identlist 2))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
917 (defmacro ada-file-of (identlist) (list 'aref identlist 3))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
918 (defmacro ada-ali-index-of (identlist) (list 'aref identlist 4))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
919 (defmacro ada-declare-file-of (identlist) (list 'aref identlist 5))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920 (defmacro ada-references-of (identlist) (list 'aref identlist 6))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
921 (defmacro ada-on-declaration (identlist) (list 'aref identlist 7))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
922
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
923 (defmacro ada-set-name (identlist name) (list 'aset identlist 0 name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
924 (defmacro ada-set-line (identlist line) (list 'aset identlist 1 line))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
925 (defmacro ada-set-column (identlist col) (list 'aset identlist 2 col))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926 (defmacro ada-set-file (identlist file) (list 'aset identlist 3 file))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
927 (defmacro ada-set-ali-index (identlist index) (list 'aset identlist 4 index))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
928 (defmacro ada-set-declare-file (identlist file) (list 'aset identlist 5 file))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
929 (defmacro ada-set-references (identlist ref) (list 'aset identlist 6 ref))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
930 (defmacro ada-set-on-declaration (ident value) (list 'aset ident 7 value))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
931
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
932 (defsubst ada-get-ali-buffer (file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
933 "Reads the ali file into a new buffer, and returns this buffer's name"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
934 (find-file-noselect (ada-get-ali-file-name file)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
935
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
936
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
937
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
938 ;; ----- Identifier Completion --------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
939 (defun ada-complete-identifier (pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
940 "Tries to complete the identifier around POS.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
941 The feature is only available if the files where compiled not using the -gnatx
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
942 option."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
943 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
944 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
945
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
946 ;; Initialize function-local variables and jump to the .ali buffer
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
947 ;; Note that for regexp search is case insensitive too
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
948 (let* ((curbuf (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
949 (identlist (ada-read-identifier pos))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
950 (sofar (concat "^[0-9]+[a-zA-Z][0-9]+[ *]\\("
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
951 (regexp-quote (ada-name-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
952 "[a-zA-Z0-9_]*\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
953 (completed nil)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
954 (symalist nil))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
955
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
956 ;; Open the .ali file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
957 (set-buffer (ada-get-ali-buffer (buffer-file-name)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
958 (goto-char (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
959
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
960 ;; build an alist of possible completions
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
961 (while (re-search-backward sofar nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
962 (setq symalist (cons (cons (match-string 1) nil) symalist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
963
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
964 (setq completed (try-completion "" symalist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
965
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
966 ;; kills .ali buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
967 (kill-buffer nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
968
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
969 ;; deletes the incomplete identifier in the buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
970 (set-buffer curbuf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
971 (looking-at "[a-zA-Z0-9_]+")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
972 (replace-match "")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
973 ;; inserts the completed symbol
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
974 (insert completed)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
975 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
976
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
977 ;; ----- Cross-referencing ----------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
978
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
979 (defun ada-point-and-xref ()
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
980 "Calls `mouse-set-point' and then `ada-goto-declaration'."
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
981 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
982 (mouse-set-point last-input-event)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
983 (ada-goto-declaration (point)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
984
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
985 (defun ada-goto-declaration (pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
986 "Display the declaration of the identifier around POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
987 The declaration is shown in another buffer if `ada-xref-other-buffer' is
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
988 non-nil."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
989 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
990 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
991 (push-mark pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
992 (ada-xref-push-pos (buffer-file-name) pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
993 (ada-find-in-ali (ada-read-identifier pos)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
994
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
995 (defun ada-goto-declaration-other-frame (pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
996 "Display the declaration of the identifier around POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
997 The declation is shown in another frame if `ada-xref-other-buffer' is non-nil."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
998 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
999 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1000 (push-mark pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1001 (ada-xref-push-pos (buffer-file-name) pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1002 (ada-find-in-ali (ada-read-identifier pos) t))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1003
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1004 (defun ada-remote (command)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1005 "Return the remote version of COMMAND, or COMMAND if remote_machine is nil."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1006 (let ((machine (ada-xref-get-project-field 'remote_machine)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1007 (if (or (not machine) (string= machine ""))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1008 command
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1009 (format "%s %s '(%s)'"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1010 remote-shell-program
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1011 machine
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1012 command))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1013
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1014 (defun ada-get-absolute-dir (dir root-dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1015 "Returns the absolute directory corresponding to DIR.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1016 If DIR is a relative directory, the value of ROOT-DIR is added in front."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1017 (if (= (string-to-char dir) ?/)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1018 dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1019 (concat root-dir dir)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1020
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1021 (defun ada-get-absolute-dir-list (dir-list root-dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1022 "Returns the list of absolute directories found in dir-list.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1023 If a directory is a relative directory, the value of ROOT-DIR is added in
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1024 front."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1025 (mapcar (lambda (x) (ada-get-absolute-dir x root-dir)) dir-list))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1026
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1027 (defun ada-set-environment ()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1028 "Return the new value for process-environment.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1029 It modifies the source path and object path with the values found in the
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1030 project file."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1031 (let ((include (getenv "ADA_INCLUDE_PATH"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1032 (objects (getenv "ADA_OBJECTS_PATH"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1033 (build-dir (ada-xref-get-project-field 'build_dir)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1034 (if include
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1035 (set 'include (concat include path-separator)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1036 (if objects
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1037 (set 'objects (concat objects path-separator)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1038 (cons
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1039 (concat "ADA_INCLUDE_PATH="
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1040 include
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1041 (mapconcat (lambda(x) (ada-get-absolute-dir x build-dir))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1042 (ada-xref-get-project-field 'src_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1043 path-separator))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1044 (cons
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1045 (concat "ADA_OBJECTS_PATH="
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1046 objects
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1047 (mapconcat (lambda(x) (ada-get-absolute-dir x build-dir))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1048 (ada-xref-get-project-field 'obj_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1049 path-separator))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1050 process-environment))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1051
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1052 (defun ada-compile-application (&optional arg)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1053 "Compiles the application, using the command found in the project file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1054 If ARG is not nil, ask for user confirmation."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1055 (interactive "P")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1056 (ada-require-project-file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1057 (let ((cmd (ada-xref-get-project-field 'make_cmd))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1058 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1059 (compilation-scroll-output t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1060
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1061 (set 'compilation-search-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1062 (ada-get-absolute-dir-list (ada-xref-get-project-field 'src_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1063 (ada-xref-get-project-field 'build_dir)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1064
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1065 ;; If no project file was found, ask the user
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1066 (unless cmd
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1067 (setq cmd "" arg t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1068
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1069 (compile (ada-remote
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1070 (if (or ada-xref-confirm-compile arg)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1071 (read-from-minibuffer "enter command to compile: " cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1072 cmd)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1073 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1074
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1075 (defun ada-compile-current (&optional arg prj-field)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1076 "Recompile the current file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1077 If ARG is not nil, ask for user confirmation of the command.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1078 PRJ-FIELD is the name of the field to use in the project file to get the
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1079 command, and should be either comp_cmd (default) or check_cmd."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1080 (interactive "P")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1081 (ada-require-project-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1082 (let* ((field (if prj-field prj-field 'comp_cmd))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1083 (cmd (ada-xref-get-project-field field))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1084 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1085 (compilation-scroll-output t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1086
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1087 (set 'compilation-search-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1088 (ada-get-absolute-dir-list (ada-xref-get-project-field 'src_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1089 (ada-xref-get-project-field 'build_dir)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1090
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1091 ;; If no project file was found, ask the user
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1092 (if cmd
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1093 (set 'cmd (concat cmd " " (ada-convert-file-name (buffer-file-name))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1094 (setq cmd "" arg t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1095
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1096 (compile (ada-remote
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1097 (if (or ada-xref-confirm-compile arg)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1098 (read-from-minibuffer "enter command to compile: " cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1099 cmd)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1100
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1101 (defun ada-check-current (&optional arg)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1102 "Recompile the current file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1103 If ARG is not nil, ask for user confirmation of the command."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1104 (interactive "P")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1105 (ada-compile-current arg 'check_cmd))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1106
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1107 (defun ada-run-application (&optional arg)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1108 "Run the application.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1109 if ARG is not-nil, asks for user confirmation."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1110 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1111 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1112
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1113 (let ((machine (ada-xref-get-project-field 'cross_prefix)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1114 (if (and machine (not (string= machine "")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1115 (error "This feature is not supported yet for cross environments")))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1116
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1117 (let ((command (ada-xref-get-project-field 'run_cmd)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1118
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1119 ;; Guess the command if it wasn't specified
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1120 (if (or (not command) (string= command ""))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1121 (set 'command (file-name-sans-extension (buffer-name))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1122
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1123 ;; Ask for the arguments to the command if required
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1124 (if (or ada-xref-confirm-compile arg)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1125 (set 'command (read-from-minibuffer "Enter command to execute: " command)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1126
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1127 ;; Modify the command to run remotely
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1128 (setq command (ada-remote command))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1129
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1130 ;; Run the command
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1131 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1132 (set-buffer (get-buffer-create "*run*"))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1133 (set 'buffer-read-only nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1134 (erase-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1135 (goto-char (point-min))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1136 (insert "\nRunning " command "\n\n")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1137 (start-process "run" (current-buffer) shell-file-name "-c" command)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1138 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1139 (display-buffer "*run*")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1140
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1141 ;; change to buffer *run* for interactive programs
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1142 (other-window 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1143 (switch-to-buffer "*run*")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1144 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1145
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1146
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1147 (defun ada-gdb-application (&optional arg)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1148 "Start the debugger on the application.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1149 If ARG is non-nil, ask the user to confirm the command."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1150 (interactive "P")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1151 (let ((buffer (current-buffer))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1152 gdb-buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1153 cmd)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1154 (ada-require-project-file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1155 (set 'cmd (ada-xref-get-project-field 'debug_cmd))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1156 (let ((machine (ada-xref-get-project-field 'remote_machine)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1157 (if (and machine (not (string= machine "")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1158 (error "This feature is not supported yet for remote environments")))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1159
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1160 ;; If the command was not given in the project file, start a bare gdb
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1161 (if (not cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1162 (set 'cmd (concat ada-prj-default-debugger
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1163 " "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1164 (file-name-sans-extension (buffer-file-name)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1165 (if (or arg ada-xref-confirm-compile)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1166 (set 'cmd (read-from-minibuffer "enter command to debug: " cmd)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1167
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1168 ;; Set the variable gud-last-last-frame so that glide-debug can find
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1169 ;; the name of the Ada file, and thus of the project file if needed.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1170 (if ada-prj-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1171 (set 'gud-last-last-frame (cons ada-prj-prj-file 1)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1172
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1173 (if (and (string-match "jdb" (comint-arguments cmd 0 0))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1174 (boundp 'jdb))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1175 (funcall (symbol-function 'jdb) cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1176 (gdb cmd))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1177
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1178 (set 'gdb-buffer (symbol-value 'gud-comint-buffer))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1179
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1180 ;; Switch back to the source buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1181 ;; and Activate the debug part in the contextual menu
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1182 (switch-to-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1183
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1184 (if (functionp 'gud-make-debug-menu)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1185 (funcall (symbol-function 'gud-make-debug-menu)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1186
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1187 ;; Warning: on Emacs >= 20.3.8, same-window-regexps includes gud-*,
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1188 ;; so the following call to display buffer will select the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1189 ;; buffer instead of displaying it in another window
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1190 ;; This is why the second argument to display-buffer is 't'
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1191 (display-buffer gdb-buffer t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1192 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1193
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1194
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1195 (defun ada-reread-prj-file (&optional filename)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1196 "Forces Emacs to read either FILENAME or the project file associated
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1197 with the current buffer.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1198 Otherwise, this file is only read once, and never read again.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1199 Since the information in the project file is shared between all buffers, this
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1200 automatically modifies the setup for all the Ada buffer that use this file."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1201 (interactive "P")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1202 (if filename
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1203 (ada-parse-prj-file filename)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1204 (ada-parse-prj-file (ada-prj-find-prj-file)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1205 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1206
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1207
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1208 ;; ------ Private routines
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1209
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1210 (defun ada-xref-current (file &optional ali-file-name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1211 "Update the cross-references for FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1212 This in fact recompiles FILE to create ALI-FILE-NAME."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1213 ;; kill old buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1214 (if (and ali-file-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1215 (get-file-buffer ali-file-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1216 (kill-buffer (get-file-buffer ali-file-name)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1217 ;; read the project file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1218 (ada-require-project-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1219 (let* ((cmd (ada-xref-get-project-field 'comp_cmd))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1220 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1221 (compilation-scroll-output t)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1222 (name (ada-convert-file-name (buffer-file-name)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1223 (body-name (ada-get-body-name name)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1224
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1225 ;; Always recompile the body when we can
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1226 (set 'body-name (or body-name name))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1227
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1228 ;; prompt for command to execute
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1229 (set 'cmd (concat cmd " " body-name))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1230 (compile (ada-remote
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1231 (if ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1232 (read-from-minibuffer "enter command to compile: " cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1233 cmd)))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1234
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1235 (defun ada-find-file-in-dir (file dir-list)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1236 "Search for FILE in DIR-LIST."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1237 (let (found)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1238 (while (and (not found) dir-list)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1239 (set 'found (concat (file-name-as-directory (car dir-list))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1240 (file-name-nondirectory file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1241
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1242 (unless (file-exists-p found)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1243 (set 'found nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1244 (set 'dir-list (cdr dir-list)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1245 found))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1246
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1247 (defun ada-find-ali-file-in-dir (file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1248 "Find an .ali file in obj_dir. The current buffer must be the Ada file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1249 Adds build_dir in front of the search path to conform to gnatmake's behavior,
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1250 and the standard runtime location at the end."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1251 (ada-find-file-in-dir file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1252 (append
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1253
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1254 ;; Add ${build_dir} in front of the path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1255 (list (ada-xref-get-project-field 'build_dir))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1256
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1257 (ada-get-absolute-dir-list
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1258 (ada-xref-get-project-field 'obj_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1259 (ada-xref-get-project-field 'build_dir))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1260
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1261 ;; Add the standard runtime at the end
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1262 ada-xref-runtime-library-ali-path)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1263
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1264 (defun ada-find-src-file-in-dir (file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1265 "Find a source file in src_dir. The current buffer must be the Ada file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1266 Adds src_dir in front of the search path to conform to gnatmake's behavior,
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1267 and the standard runtime location at the end."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1268 (ada-find-file-in-dir file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1269 (append
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1270
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1271 ;; Add ${build_dir} in front of the path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1272 (list (ada-xref-get-project-field 'build_dir))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1273
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1274 (ada-get-absolute-dir-list
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1275 (ada-xref-get-project-field 'src_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1276 (ada-xref-get-project-field 'build_dir))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1277
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1278 ;; Add the standard runtime at the end
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1279 ada-xref-runtime-library-specs-path)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1280
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1281
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1282 (defun ada-get-ali-file-name (file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1283 "Create the ali file name for the ada-file FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1284 The file is searched for in every directory shown in the obj_dir lines of
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1285 the project file."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1286
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1287 ;; This function has to handle the special case of non-standard
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1288 ;; file names (i.e. not .adb or .ads)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1289 ;; The trick is the following:
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1290 ;; 1- replace the extension of the current file with .ali,
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1291 ;; and look for this file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1292 ;; 2- If this file is found:
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1293 ;; grep the "^U" lines, and make sure we are not reading the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1294 ;; .ali file for a spec file. If we are, go to step 3.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1295 ;; 3- If the file is not found or step 2 failed:
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1296 ;; find the name of the "other file", ie the body, and look
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1297 ;; for its associated .ali file by subtituing the extension
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1298
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1299 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1300 (set-buffer (get-file-buffer file))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1301 (let ((short-ali-file-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1302 (concat (file-name-sans-extension (file-name-nondirectory file))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1303 ".ali"))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1304 ali-file-name)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1305 ;; First step
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1306 ;; we take the first possible completion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1307 (setq ali-file-name (ada-find-ali-file-in-dir short-ali-file-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1308
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1309 ;; If we have found the .ali file, but the source file was a spec
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1310 ;; with a non-standard name, search the .ali file for the body if any,
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1311 ;; since the xref information is more complete in that one
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1312 (unless ali-file-name
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1313 (if (not (string= (file-name-extension file) "ads"))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1314 (let ((is-spec nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1315 (specs ada-spec-suffixes)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1316 body-ali)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1317 (while specs
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1318 (if (string-match (concat (regexp-quote (car specs)) "$")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1319 file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1320 (set 'is-spec t))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1321 (set 'specs (cdr specs)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1322
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1323 (if is-spec
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1324 (set 'body-ali
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1325 (ada-find-ali-file-in-dir
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1326 (concat (file-name-sans-extension
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1327 (file-name-nondirectory
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1328 (ada-other-file-name)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1329 ".ali"))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1330 (if body-ali
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1331 (set 'ali-file-name body-ali))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1332
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1333 ;; else we did not find the .ali file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1334 ;; Second chance: in case the files do not have standard names (such
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1335 ;; as for instance file_s.ada and file_b.ada), try to go to the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1336 ;; other file and look for its ali file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1337 (setq short-ali-file-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1338 (concat (file-name-sans-extension
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1339 (file-name-nondirectory (ada-other-file-name)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1340 ".ali"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1341 (setq ali-file-name (ada-find-ali-file-in-dir short-ali-file-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1342
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1343 ;; If still not found, try to recompile the file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1344 (if (not ali-file-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1345 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1346 ;; recompile only if the user asked for this
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1347 (if ada-xref-create-ali
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1348 (ada-xref-current file ali-file-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1349 (error "Ali file not found. Recompile your file")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1350 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1351
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1352 ;; same if the .ali file is too old and we must recompile it
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1353 (if (and (file-newer-than-file-p file ali-file-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1354 ada-xref-create-ali)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1355 (ada-xref-current file ali-file-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1356
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1357 ;; else returns the correct absolute file name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1358 (expand-file-name ali-file-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1359 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1360
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1361 (defun ada-get-ada-file-name (file original-file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1362 "Create the complete file name (+directory) for FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1363 The original file (where the user was) is ORIGINAL-FILE. Search in project
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1364 file for possible paths."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1365
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1366 (save-excursion
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1367
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1368 ;; If the buffer for original-file, use it to get the values from the
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1369 ;; project file, otherwise load the file and its project file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1370 (let ((buffer (get-file-buffer original-file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1371 (if buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1372 (set-buffer buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1373 (find-file original-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1374 (ada-require-project-file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1375
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1376 ;; we choose the first possible completion and we
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1377 ;; return the absolute file name
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1378 (let ((filename (ada-find-src-file-in-dir file)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1379 (if filename
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1380 (expand-file-name filename)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1381 (error (concat
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1382 (file-name-nondirectory file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1383 " not found in src_dir. Please check your project file")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1384
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1385 )))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1386
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1387 (defun ada-find-file-number-in-ali (file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1388 "Returns the file number for FILE in the associated ali file."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1389 (set-buffer (ada-get-ali-buffer file))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1390 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1391
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1392 (let ((begin (re-search-forward "^D")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1393 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1394 (re-search-forward (concat "^D " (file-name-nondirectory file)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1395 (count-lines begin (point))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1396
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1397 (defun ada-read-identifier (pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1398 "Returns the identlist around POS and switch to the .ali buffer."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1399
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1400 ;; If there's a compilation in progress, it's probably because the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1401 ;; .ali file didn't exist. So we should wait...
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1402 (if compilation-in-progress
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1403 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1404 (message "Compilation in progress. Try again when it is finished")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1405 (set 'quit-flag t)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1406
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1407 ;; If at end of buffer (e.g the buffer is empty), error
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1408 (if (>= (point) (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1409 (error "No identifier on point"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1410
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1411 ;; goto first character of the identifier/operator (skip backward < and >
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1412 ;; since they are part of multiple character operators
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1413 (goto-char pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1414 (skip-chars-backward "a-zA-Z0-9_<>")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1415
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1416 ;; check if it really is an identifier
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1417 (if (ada-in-comment-p)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1418 (error "Inside comment"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1419
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1420 (let (identifier identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1421 ;; Just in front of a string => we could have an operator declaration,
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1422 ;; as in "+", "-", ..
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1423 (if (= (char-after) ?\")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1424 (forward-char 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1425
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1426 ;; if looking at an operator
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1427 ;; This is only true if:
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1428 ;; - the symbol is +, -, ...
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1429 ;; - the symbol is made of letters, and not followed by _ or a letter
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1430 (if (and (looking-at ada-operator-re)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1431 (or (not (= (char-syntax (char-after)) ?w))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1432 (not (or (= (char-syntax (char-after (match-end 0))) ?w)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1433 (= (char-after (match-end 0)) ?_)))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1434 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1435 (if (and (= (char-before) ?\")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1436 (= (char-after (+ (length (match-string 0)) (point))) ?\"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1437 (forward-char -1))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1438 (set 'identifier (regexp-quote (concat "\"" (match-string 0) "\""))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1439
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1440 (if (ada-in-string-p)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1441 (error "Inside string or character constant"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1442 (if (looking-at (concat ada-keywords "[^a-zA-Z_]"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1443 (error "No cross-reference available for reserved keyword"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1444 (if (looking-at "[a-zA-Z0-9_]+")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1445 (set 'identifier (match-string 0))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1446 (error "No identifier around")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1447
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1448 ;; Build the identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1449 (set 'identlist (ada-make-identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1450 (ada-set-name identlist (downcase identifier))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1451 (ada-set-line identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1452 (number-to-string (count-lines (point-min) (point))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1453 (ada-set-column identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1454 (number-to-string (1+ (current-column))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1455 (ada-set-file identlist (buffer-file-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1456 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1457 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1458
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1459 (defun ada-get-all-references (identlist)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1460 "Completes and returns IDENTLIST with the information extracted
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1461 from the ali file (definition file and places where it is referenced)."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1462
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1463 (let ((ali-buffer (ada-get-ali-buffer (ada-file-of identlist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1464 declaration-found)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1465 (set-buffer ali-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1466 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1467 (ada-set-on-declaration identlist nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1468
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1469 ;; First attempt: we might already be on the declaration of the identifier
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1470 ;; We want to look for the declaration only in a definite interval (after
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1471 ;; the "^X ..." line for the current file, and before the next "^X" line
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1472
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1473 (if (re-search-forward
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1474 (concat "^X [0-9]+ " (file-name-nondirectory (ada-file-of identlist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1475 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1476 (let ((bound (save-excursion (re-search-forward "^X " nil t))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1477 (set 'declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1478 (re-search-forward
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1479 (concat "^" (ada-line-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1480 "." (ada-column-of identlist)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1481 "[ *]" (ada-name-of identlist)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1482 " \\(.*\\)$") bound t))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1483 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1484 (ada-set-on-declaration identlist t))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1485 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1486
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1487 ;; If declaration is still nil, then we were not on a declaration, and
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1488 ;; have to fall back on other algorithms
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1489
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1490 (unless declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1491
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1492 ;; Since we alread know the number of the file, search for a direct
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1493 ;; reference to it
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1494 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1495 (set 'declaration-found t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1496 (ada-set-ali-index
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1497 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1498 (number-to-string (ada-find-file-number-in-ali
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1499 (ada-file-of identlist))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1500 (unless (re-search-forward (concat (ada-ali-index-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1501 "|\\([0-9]+.[0-9]+ \\)*"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1502 (ada-line-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1503 "[^0-9]"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1504 (ada-column-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1505 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1506
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1507 ;; if we did not find it, it may be because the first reference
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1508 ;; is not required to have a 'unit_number|' item included.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1509 ;; Or maybe we are already on the declaration...
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1510 (unless (re-search-forward (concat "^\\([a-zA-Z0-9_.\"]+[ *]\\)*"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1511 (ada-line-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1512 "[^0-9]"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1513 (ada-column-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1514 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1515
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1516 ;; If still not found, then either the declaration is unknown
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1517 ;; or the source file has been modified since the ali file was
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1518 ;; created
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1519 (set 'declaration-found nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1520 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1521 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1522
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1523 ;; Last check to be completly sure we have found the correct line (the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1524 ;; ali might not be up to date for instance)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1525 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1526 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1527 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1528 ;; while we have a continuation line, go up one line
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1529 (while (looking-at "^\\.")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1530 (previous-line 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1531 (unless (looking-at (concat "[0-9]+.[0-9]+[ *]"
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1532 (ada-name-of identlist) "[ <]"))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1533 (set 'declaration-found nil))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1534
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1535 ;; Still no success ! The ali file must be too old, and we need to
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1536 ;; use a basic algorithm based on guesses. Note that this only happens
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1537 ;; if the user does not want us to automatically recompile files
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1538 ;; automatically
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1539 (unless declaration-found
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1540 (if (ada-xref-find-in-modified-ali identlist)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1541 (set 'declaration-found t)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1542 ;; no more idea to find the declaration. Give up
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1543 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1544 (kill-buffer ali-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1545 (error (concat "No declaration of " (ada-name-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1546 " found."))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1547 )))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1548 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1549
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1550
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1551 ;; Now that we have found a suitable line in the .ali file, get the
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1552 ;; information available
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1553 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1554 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1555 (let ((current-line (buffer-substring
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1556 (point) (save-excursion (end-of-line) (point)))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1557 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1558 (next-line 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1559 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1560 (while (looking-at "^\\.\\(.*\\)")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1561 (set 'current-line (concat current-line (match-string 1)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1562 (next-line 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1563 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1564
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1565 (if (re-search-backward "^X [0-9]+ \\([a-zA-Z0-9_.-]+\\)" nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1566 (ada-set-declare-file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1567 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1568 (ada-get-ada-file-name (match-string 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1569 (ada-file-of identlist))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1570
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1571 (ada-set-references identlist current-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1572 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1573 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1574
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1575 (defun ada-xref-find-in-modified-ali (identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1576 "Find the matching position for IDENTLIST in the current ali buffer.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1577 This function is only called when the file was not up-to-date, so we need
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1578 to make some guesses.
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1579 This function is disabled for operators, and only works for identifiers."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1580
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1581 (unless (= (string-to-char (ada-name-of identlist)) ?\")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1582 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1583 (let ((declist '()) ;;; ( (line_in_ali_file line_in_ada) ( ... ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1584 (my-regexp (concat "[ *]"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1585 (regexp-quote (ada-name-of identlist)) " "))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1586 (line-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1587 (col-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1588 (line-ali 0)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1589 (len 0)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1590 (choice 0)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1591 (ali-buffer (current-buffer)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1592
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1593 (goto-char (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1594 (while (re-search-backward my-regexp nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1595 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1596 (set 'line-ali (count-lines (point-min) (point)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1597 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1598 ;; have a look at the line and column numbers
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1599 (if (looking-at "^\\([0-9]+\\).\\([0-9]+\\)[ *]")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1600 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1601 (setq line-ada (match-string 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1602 (setq col-ada (match-string 2)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1603 (setq line-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1604 (setq col-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1605 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1606 ;; construct a list with the file names and the positions within
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1607 (if (re-search-backward "^X [0-9]+ \\([a-zA-Z0-9._-]+\\)" nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1608 (add-to-list
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1609 'declist (list line-ali (match-string 1) line-ada col-ada))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1610 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1611 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1612 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1613
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1614 ;; how many possible declarations have we found ?
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1615 (setq len (length declist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1616 (cond
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1617 ;; none => error
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1618 ((= len 0)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1619 (kill-buffer (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1620 (error (concat "No declaration of "
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1621 (ada-name-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1622 " recorded in .ali file")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1623
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1624 ;; one => should be the right one
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1625 ((= len 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1626 (goto-line (caar declist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1627
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1628 ;; more than one => display choice list
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1629 (t
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1630 (with-output-to-temp-buffer "*choice list*"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1631
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1632 (princ "Identifier is overloaded and Xref information is not up to date.\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1633 (princ "Possible declarations are:\n\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1634 (princ " no. in file at line col\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1635 (princ " --- --------------------- ---- ----\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1636 (let ((counter 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1637 (while (<= counter len)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1638 (princ (format " %2d) %-21s %4s %4s\n"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1639 counter
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1640 (ada-get-ada-file-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1641 (nth 1 (nth (1- counter) declist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1642 (ada-file-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1643 (nth 2 (nth (1- counter) declist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1644 (nth 3 (nth (1- counter) declist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1645 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1646 (setq counter (1+ counter))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1647 ) ; end of while
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1648 ) ; end of let
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1649 ) ; end of with-output-to ...
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1650 (setq choice nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1651 (while (or
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1652 (not choice)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1653 (not (integerp choice))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1654 (< choice 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1655 (> choice len))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1656 (setq choice (string-to-int
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1657 (read-from-minibuffer "Enter No. of your choice: "))))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1658 (set-buffer ali-buffer)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1659 (goto-line (car (nth (1- choice) declist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1660 ))))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1661
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1662
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1663 (defun ada-find-in-ali (identlist &optional other-frame)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1664 "Look in the .ali file for the definition of the identifier in IDENTLIST.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1665 If OTHER-FRAME is non nil, and `ada-xref-other-buffer' is non nil,
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1666 opens a new window to show the declaration."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1667
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1668 (ada-get-all-references identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1669 (let ((ali-line (ada-references-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1670 file line col)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1671
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1672 ;; If we were on a declaration, go to the body
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1673 (if (ada-on-declaration identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1674 (if (string-match "\\([0-9]+\\)[bc]\\([0-9]+\\)" ali-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1675 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1676 (setq line (match-string 1 ali-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1677 col (match-string 2 ali-line))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1678 ;; it there was a file number in the same line
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1679 (if (string-match "\\([0-9]+\\)|\\([^|bc]+\\)?[bc]" ali-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1680 (let ((file-number (match-string 1 ali-line)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1681 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1682 (re-search-forward "^D \\([a-zA-Z0-9_.-]+\\)" nil t
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1683 (string-to-number file-number))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1684 (set 'file (match-string 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1685 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1686 ;; Else get the nearest file
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1687 (set 'file (ada-declare-file-of identlist))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1688 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1689 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1690 (error "No body found"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1691
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1692 ;; Else we were not on the declaration, find the place for it
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1693 (string-match "\\([0-9]+\\)[a-zA-Z+]\\([0-9]+\\)[ *]" ali-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1694 (setq line (match-string 1 ali-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1695 col (match-string 2 ali-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1696 file (ada-declare-file-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1697 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1698
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1699 ;; Now go to the buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1700 (ada-xref-change-buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1701 (ada-get-ada-file-name file (ada-file-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1702 (string-to-number line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1703 (1- (string-to-number col))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1704 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1705 other-frame)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1706 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1707
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1708 (defun ada-xref-change-buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1709 (file line column identlist &optional other-frame)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1710 "Select and display FILE, at LINE and COLUMN. The new file is
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1711 associated with the same project file as the one for IDENTLIST.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1712 If we do not end on the same identifier as IDENTLIST, find the closest
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1713 match. Kills the .ali buffer at the end.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1714 If OTHER-FRAME is non-nil, creates a new frame to show the file."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1715
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1716 (let (prj-file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1717 declaration-buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1718 (ali-buffer (current-buffer)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1719
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1720 ;; get the current project file for the source ada file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1721 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1722 (set-buffer (get-file-buffer (ada-file-of identlist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1723 (set 'prj-file ada-prj-prj-file))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1724
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1725 ;; Select and display the destination buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1726 (if ada-xref-other-buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1727 (if other-frame
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1728 (find-file-other-frame file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1729 (set 'declaration-buffer (find-file-noselect file))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1730 (set-buffer declaration-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1731 (switch-to-buffer-other-window declaration-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1732 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1733 (find-file file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1734 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1735
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1736 ;; If the new buffer is not already associated with a project file, do it
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1737 (unless (my-local-variable-if-set-p 'ada-prj-prj-file (current-buffer))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1738 (set (make-local-variable 'ada-prj-prj-file) prj-file))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1739
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1740 ;; move the cursor to the correct position
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1741 (push-mark)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1742 (goto-line line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1743 (move-to-column column)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1744
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1745 ;; If we are not on the identifier, the ali file was not up-to-date.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1746 ;; Try to find the nearest position where the identifier is found,
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1747 ;; this is probably the right one.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1748 (unless (looking-at (ada-name-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1749 (ada-xref-search-nearest (ada-name-of identlist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1750
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1751 (kill-buffer ali-buffer)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1752
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1753
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1754 (defun ada-xref-search-nearest (name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1755 "Searches for NAME nearest to the position recorded in the Xref file.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1756 It returns the position of the declaration in the buffer or nil if not found."
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1757 (let ((orgpos (point))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1758 (newpos nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1759 (diff nil))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1760
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1761 (goto-char (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1762
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1763 ;; loop - look for all declarations of name in this file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1764 (while (search-backward name nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1765
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1766 ;; check if it really is a complete Ada identifier
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1767 (if (and
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1768 (not (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1769 (goto-char (match-end 0))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1770 (looking-at "_")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1771 (not (ada-in-string-or-comment-p))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1772 (or
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1773 ;; variable declaration ?
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1774 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1775 (skip-chars-forward "a-zA-Z_0-9" )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1776 (ada-goto-next-non-ws)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1777 (looking-at ":[^=]"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1778 ;; procedure, function, task or package declaration ?
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1779 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1780 (ada-goto-previous-word)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1781 (looking-at "\\<[pP][rR][oO][cC][eE][dD][uU][rR][eE]\\>\\|\\<[fF][uU][nN][cC][tT][iI][oO][nN]\\>\\|\\<[tT][yY][pP][eE]\\>\\|\\<[tT][aA][sS][kK]\\>\\|\\<[pP][aA][cC][kK][aA][gG][eE]\\>\\|\\<[bB][oO][dD][yY]\\>"))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1782
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1783 ;; check if it is nearer than the ones before if any
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1784 (if (or (not diff)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1785 (< (abs (- (point) orgpos)) diff))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1786 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1787 (setq newpos (point)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1788 diff (abs (- newpos orgpos))))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1789 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1790
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1791 (if newpos
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1792 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1793 (message "ATTENTION: this declaration is only a (good) guess ...")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1794 (goto-char newpos))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1795 nil)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1796
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1797
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1798 ;; Find the parent library file of the current file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1799 (defun ada-goto-parent ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1800 "Go to the parent library file."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1801 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1802 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1803
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1804 (let ((buffer (ada-get-ali-buffer (buffer-file-name)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1805 (unit-name nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1806 (body-name nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1807 (ali-name nil))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1808 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1809 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1810 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1811 (re-search-forward "^U \\([^ \t%]+\\)%[bs][ \t]+\\([^ \t]+\\)")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1812 (setq unit-name (match-string 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1813 (if (not (string-match "\\(.*\\)\\.[^.]+" unit-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1814 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1815 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1816 (error "No parent unit !"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1817 (setq unit-name (match-string 1 unit-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1818 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1819
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1820 ;; look for the file name for the parent unit specification
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1821 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1822 (re-search-forward (concat "^W " unit-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1823 "%s[ \t]+\\([^ \t]+\\)[ \t]+"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1824 "\\([^ \t\n]+\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1825 (setq body-name (match-string 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1826 (setq ali-name (match-string 2))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1827 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1828 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1829
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1830 (setq ali-name (ada-find-ali-file-in-dir ali-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1831
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1832 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1833 ;; Tries to open the new ali file to find the spec file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1834 (if ali-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1835 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1836 (find-file ali-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1837 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1838 (re-search-forward (concat "^U " unit-name "%s[ \t]+"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1839 "\\([^ \t]+\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1840 (setq body-name (match-string 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1841 (kill-buffer (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1842 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1843 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1844 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1845
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1846 (find-file body-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1847 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1848
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1849 (defun ada-make-filename-from-adaname (adaname)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1850 "Determine the filename in which ADANAME is found.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1851 This is a GNAT specific function that uses gnatkrunch."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1852 (let (krunch-buf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1853 (setq krunch-buf (generate-new-buffer "*gkrunch*"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1854 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1855 (set-buffer krunch-buf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1856 ;; send adaname to external process `gnatkr'.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1857 (call-process "gnatkr" nil krunch-buf nil
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1858 adaname ada-krunch-args)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1859 ;; fetch output of that process
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1860 (setq adaname (buffer-substring
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1861 (point-min)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1862 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1863 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1864 (end-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1865 (point))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1866 (kill-buffer krunch-buf)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1867 adaname
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1868 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1869
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1870 (defun ada-make-body-gnatstub ()
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1871 "Create an Ada package body in the current buffer.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1872 This function uses the `gnatstub' program to create the body.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1873 This function typically is to be hooked into `ff-file-created-hooks'."
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1874 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1875
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1876 (save-some-buffers nil nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1877
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1878 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1879
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1880 (delete-region (point-min) (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1881
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1882 ;; Call the external process gnatstub
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1883 (let* ((gnatstub-opts (ada-treat-cmd-string ada-gnatstub-opts))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1884 (filename (buffer-file-name (car (cdr (buffer-list)))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1885 (output (concat (file-name-sans-extension filename) ".adb"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1886 (gnatstub-cmd (concat "gnatstub " gnatstub-opts " " filename))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1887 (buffer (get-buffer-create "*gnatstub*")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1888
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1889 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1890 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1891 (compilation-minor-mode 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1892 (erase-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1893 (insert gnatstub-cmd)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1894 (newline)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1895 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1896 ;; call gnatstub to create the body file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1897 (call-process shell-file-name nil buffer nil "-c" gnatstub-cmd)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1898
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1899 (if (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1900 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1901 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1902 (search-forward "command not found" nil t))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1903 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1904 (message "gnatstub was not found -- using the basic algorithm")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1905 (sleep-for 2)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1906 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1907 (ada-make-body))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1908
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1909 ;; Else clean up the output
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1910
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1911 ;; Kill the temporary buffer created by find-file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1912 (set-buffer-modified-p nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1913 (kill-buffer (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1914
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1915 (if (file-exists-p output)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1916 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1917 (find-file output)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1918 (kill-buffer buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1919
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1920 ;; display the error buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1921 (display-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1922 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1923 )))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1924
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1925
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1926 (defun ada-xref-initialize ()
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1927 "Function called by ada-mode-hook to initialize the ada-xref.el package.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1928 For instance, it creates the gnat-specific menus, set some hooks for
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1929 find-file...."
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1930 (make-local-hook 'ff-file-created-hooks)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1931 (setq ff-file-created-hooks 'ada-make-body-gnatstub)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1932
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1933 ;; Read the project file and update the search path
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1934 ;; before looking for the other file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1935 (make-local-hook 'ff-pre-find-hooks)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1936 (add-hook 'ff-pre-find-hooks 'ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1937
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1938 ;; Completion for file names in the mini buffer should ignore .ali files
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1939 (add-to-list 'completion-ignored-extensions ".ali")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1940 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1941
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1942
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1943 ;; ----- Add to ada-mode-hook ---------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1944
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1945 ;; Set the keymap once and for all, so that the keys set by the user in his
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1946 ;; config file are not overwritten every time we open a new file.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1947 (ada-add-ada-menu)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1948 (ada-add-keymap)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1949
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1950 (add-hook 'ada-mode-hook 'ada-xref-initialize)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1951
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1952 ;; Use ddd as the default debugger if it was found
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1953 (if (ada-find-file-in-dir "ddd" exec-path)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1954 (set 'ada-prj-default-debugger "ddd --tty -fullname -toolbar"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1955
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1956 ;; Initializes the cross references to the runtime library
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1957 (ada-initialize-runtime-library)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1958
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1959 ;; Add these standard directories to the search path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1960 (set 'ada-search-directories
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1961 (append (mapcar 'directory-file-name ada-xref-runtime-library-specs-path)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1962 ada-search-directories))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1963
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1964 ;; Make sure that the files are always associated with a project file. Since
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1965 ;; the project file has some fields that are used for the editor (like the
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1966 ;; casing exceptions), it has to be read before the user edits a file).
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1967 (add-hook 'ada-mode-hook
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1968 (lambda()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1969 (let ((file (ada-prj-find-prj-file t)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1970 (if file (ada-reread-prj-file file)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1971
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1972 (provide 'ada-xref)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1973
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1974 ;;; ada-xref.el ends here