annotate lisp/progmodes/ada-xref.el @ 89360:a0f862213ebb

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Fri, 10 Jan 2003 07:42:18 +0000
parents ceb40bd97a77
children f200fce92816
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38401
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
32301
0f1f7e931493 Fix header line, copyright notice.
Dave Love <fx@gnu.org>
parents: 30408
diff changeset
3 ;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 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>
38441
ceb40bd97a77 (ada-xref-initialize): Fix call to add-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
9 ;; Ada Core Technologies's version: $Revision: 1.7 $
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
38361
d42c9135a92d Say that the file _is_ part of Emacs.
Eli Zaretskii <eliz@gnu.org>
parents: 32301
diff changeset
12 ;; This file is part of GNU Emacs.
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13
38401
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
25899
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
38401
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
25899
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
38401
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
27 ;; Boston, MA 02111-1307, USA.
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;; Commentary:
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;;; 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
31 ;;; 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
32 ;;; 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
33 ;;;
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;; 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
35 ;;; - `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
36 ;;; 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
37 ;;; - `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
38 ;;; 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
39 ;;; buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;; - `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
41 ;;; 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
42 ;;; another buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;;; - `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
44 ;; 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
45 ;;; - `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
46 ;;; that a project file exists in your directory
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
47 ;;; - `ada-run-application': run your application directly from Emacs
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
48 ;;; - `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
49 ;;; 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
50 ;;; 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
51 ;;; - `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
52 ;;; - `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
53 ;;; every new buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;;;
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;;; 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
56 ;;; 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
57 ;;; 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
58
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;;; 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
60
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38401
diff changeset
61 ;;; Code:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38401
diff changeset
62
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;; ----- Requirements -----------------------------------------------------
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 (require 'compile)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (require 'comint)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; ------ Use variables
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 (defcustom ada-xref-other-buffer t
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
70 "*If nil, always display the cross-references in the same buffer.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
71 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
72 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 (defcustom ada-xref-create-ali t
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
75 "*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
76 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
77 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 (defcustom ada-xref-confirm-compile nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
80 "*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
81 the application."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 (defcustom ada-krunch-args "0"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
85 "*Maximum number of characters for filenames created by gnatkr.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
86 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
87 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
89 (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
90 "Default compilation options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
91 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
92
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
93 (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
94 "Default binder options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
95 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
96
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
97 (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
98 "Default linker options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
99 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
100
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
101 (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
102 "Default options for gnatmake."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
103 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
104
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
105 (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
106 "${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
107 "*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
108 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
109 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
110 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
111
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
112 (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
113 "*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
114 `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
115 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (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
118 (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
119 "-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
120 "*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
121 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
122 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (defcustom ada-prj-default-project-file ""
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
125 "*Name of the project file to use for every Ada file.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
126 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
127 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
128 :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
129
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (defcustom ada-gnatstub-opts "-q -I${src_dir}"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
131 "*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
132 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
133 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (defcustom ada-always-ask-project nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
136 "*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
137 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
138 :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
139
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 ;; ------- 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
141 (defvar ada-last-prj-file ""
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
142 "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
143
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
144 (defvar ada-check-switch "-gnats"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
145 "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
146
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (defvar ada-project-file-extension ".adp"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
148 "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
149
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (defconst is-windows (memq system-type (quote (windows-nt)))
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
151 "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
152
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
153 (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
154 "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
155 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
156
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
157 (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
158 "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
159 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
160
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 (defvar ada-xref-pos-ring '()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
162 "List of positions selected by the cross-references functions.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
163 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
164
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 (defconst ada-xref-pos-ring-max 16
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
166 "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
167
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 (defvar ada-operator-re
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
169 "\\+\\|-\\|/\\|\\*\\*\\|\\*\\|=\\|&\\|abs\\|mod\\|rem\\|and\\|not\\|or\\|xor\\|<=\\|<\\|>=\\|>"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
170 "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
171
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (defvar ada-xref-default-prj-file nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
173 "Name of the default prj file, per directory.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
174 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
175 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
176 Emacs session.")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
178
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
179 (defvar ada-xref-project-files '()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
180 "Associative list of project files.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
181 It has the following format:
38441
ceb40bd97a77 (ada-xref-initialize): Fix call to add-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
182 \((project_name . value) (project_name . value) ...)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
183 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
184
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (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
186 "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
187 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
188
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
189 (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
190 "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
191 (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
192 (save-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
193 (set-buffer buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
194 (symbol-value variable))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
195
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
196 (defun ada-initialize-runtime-library ()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
197 "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
198 (save-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
199 (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
200 (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
201 (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
202 (widen)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
203 (erase-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
204 ;; 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
205 (condition-case nil
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
206 ;; 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
207 (unwind-protect
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
208 (progn
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
209 (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
210 (goto-char (point-min))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
211
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
212 ;; Source path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
213
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
214 (search-forward "Source Search Path:")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
215 (forward-line 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
216 (while (not (looking-at "^$"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
217 (back-to-indentation)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
218 (unless (looking-at "<Current_Directory>")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
219 (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
220 (buffer-substring-no-properties
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
221 (point)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
222 (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
223 (forward-line 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
224
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
225 ;; Object path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
226
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
227 (search-forward "Object Search Path:")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
228 (forward-line 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
229 (while (not (looking-at "^$"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
230 (back-to-indentation)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
231 (unless (looking-at "<Current_Directory>")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
232 (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
233 (buffer-substring-no-properties
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
234 (point)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
235 (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
236 (forward-line 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
237 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
238 (kill-buffer nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
239 (error nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
240 (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
241 (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
242 (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
243 (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
244 ))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
245
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
246
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
247 (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
248 "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
249 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
250 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
251 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
252
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
253 (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
254 (let (value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
255 (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
256 (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
257 (save-match-data
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
258 (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
259 (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
260 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
261 ((null value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
262 (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
263 ((stringp value)
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 value t t cmd-string)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
265 ((listp value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
266 (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
267 (set 'cmd-string (replace-match
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
268 (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
269 t t cmd-string)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
270 ))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
271 cmd-string)
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 (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
274 "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
275
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
276 (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
277 plist)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
278 (save-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
279 (set-buffer ada-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
280
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
281 (set 'plist
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
282 ;; 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
283 ;; 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
284 ;; 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
285 (list 'filename (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
286 (file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
287 (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
288 (ada-prj-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
289 ada-prj-prj-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
290 (ada-xref-default-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
291 ada-xref-default-prj-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
292 (t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
293 (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
294 "and no default project "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
295 "file specified!"))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
296 '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
297 'src_dir (list ".")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
298 'obj_dir (list ".")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
299 '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
300 ada-case-exception-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
301 (list ada-case-exception-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
302 '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
303 '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
304 '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
305 '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
306 'main (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
307 (file-name-sans-extension file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
308 "")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
309 'main_unit (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
310 (file-name-nondirectory
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
311 (file-name-sans-extension file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
312 "")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
313 'cross_prefix ""
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
314 'remote_machine ""
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
315 '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
316 ada-prj-default-comp-cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
317 '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
318 ada-check-switch)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
319 '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
320 ada-prj-default-make-cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
321 '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
322 (if is-windows ".exe"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
323 '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
324 (if is-windows " ${main}.exe"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
325 " ${main}"))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
326 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
327 (set symbol plist)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
328
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
329 (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
330 "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
331 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
332 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
333
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
334 (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
335 file value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
336
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
337 ;; 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
338 ;; 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
339 (if (and (not file-name)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
340 ada-prj-default-project-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
341 (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
342 (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
343
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
344 (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
345
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
346 ;; 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
347 (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
348 ;; 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
349 (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
350
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
351 ;; 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
352 (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
353 (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
354 (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
355 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
356 (if (stringp value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
357 (ada-treat-cmd-string value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
358 value))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
359 )
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 ;; ----- Keybindings ------------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (defun ada-add-keymap ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
364 "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
365 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (if ada-xemacs
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (progn
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 '(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
369 (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
370 (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
371 (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
372
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-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
374 (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
375 (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
376 (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
377 (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
378 (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
379 (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
380 (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
381 (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
382 (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
383 (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
384 (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
385 (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
386 (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
387 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 ;; ----- Menus --------------------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (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
391 "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
392 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
393 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
394 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (if ada-xemacs
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
396 (let* ((menu-list '("Ada"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
397 (goto-menu '("Ada" "Goto"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
398 (edit-menu '("Ada" "Edit"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
399 (help-menu '("Ada" "Help"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
400 (options-menu (list "Ada" "Options")))
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 ["Check file" ada-check-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 ["Compile file" ada-compile-current
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
406 (string= mode-name "Ada")] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
407 (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
408 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
409 (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
410 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
411 (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
412 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
413 (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
414 menu-list ["--" nil t] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
415 (funcall (symbol-function 'add-submenu)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
416 menu-list '("Project"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
417 ["Associate" ada-change-prj t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
418 ["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
419 ["List" ada-buffer-list t])
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
420 "Goto")
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 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
423 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
424 (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
425 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
426 ada-find-any-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 ["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
430 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
431 (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
432 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
433 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
434 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
435 (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
436 goto-menu ["Goto Declaration/Body"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
437 ada-goto-declaration t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
438 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
439 (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
440 goto-menu ["Goto Previous Reference"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
441 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
442 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
443 (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
444 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
445 (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
446 edit-menu ["Complete Identifier"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
447 ada-complete-identifier t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
448 "Indent Line")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
449 (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
450 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
451 (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
452 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
453 (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
454 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
455 (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
456 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
457 (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
458 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
459 (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
460 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
461 (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
462 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
463 ["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
464 (setq ada-xref-other-buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
465 (not ada-xref-other-buffer))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
466 :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
467 (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
468 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
469 ["Automatically Recompile for Cross-References"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
470 (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
471 :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
472 (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
473 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
474 ["Confirm Commands"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
475 (setq ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
476 (not ada-xref-confirm-compile))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
477 :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
478 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
479
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 ;; for Emacs
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
481 (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
482 (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
483 (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
484 (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
485 (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
486
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
487 (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
488 'Customize)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
489 (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
490 'Check)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
491 (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
492 'Compile)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
493 (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
494 (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
495 (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
496 (define-key-after menu [Project]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
497 (cons "Project"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
498 (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
499 "Project"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
500 '(["Associate..." ada-change-prj t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
501 :included (string= mode-name "Ada")]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
502 ["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
503 ["List" ada-buffer-list t])))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
504 'rem)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
506 (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
507 '("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
508 (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
509 '("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
510 (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
511 '("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
512 (define-key help-menu [gdb]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
513 '("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
514 (define-key help-menu [gdb]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
515 '("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
516
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
517 (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
518 (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
519 . ada-goto-parent))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
520 (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
521 '("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
522 (define-key goto-menu [References]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
523 '("List References" . ada-find-references))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
524 (define-key goto-menu [Prev]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
525 '("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
526 (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
527 '("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
528 (define-key goto-menu [Decl]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
529 '("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
530
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
531 (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
532 (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
533 . ada-complete-identifier))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
534
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
535 (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
536 '(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
537 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
538 (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
539 :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
540 (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
541 '(menu-item "Confirm Commands"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
542 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
543 (setq ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
544 (not ada-xref-confirm-compile)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
545 :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
546 (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
547 '(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
548 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
549 (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
550 :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
551 )
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
552 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
553 )
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 ;; ----- Utilities -------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (defun ada-require-project-file ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
558 "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
559 (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
560 (ada-reread-prj-file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
561
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (defun ada-xref-push-pos (filename position)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
563 "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
564 (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
565 (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
566 (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
567
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (defun ada-xref-goto-previous-reference ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
569 "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
570 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 (if ada-xref-pos-ring
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
572 (let ((pos (car ada-xref-pos-ring)))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
573 (setq ada-xref-pos-ring (cdr ada-xref-pos-ring))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
574 (find-file (car (cdr pos)))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
575 (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
576
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (defun ada-convert-file-name (name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
578 "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
579 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
580 name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (defun ada-set-default-project-file (name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
583 "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
584 (interactive "fProject file:")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
585
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
586 ;; 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
587 ;; 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
588 (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
589
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (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
591
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
592 ;; 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
593 ;; 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
594 ;; 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
595 (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
596
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
597 (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
598 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
600 ;; ------ 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
601
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (defun ada-prj-find-prj-file (&optional no-user-question)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
603 "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
604 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
605 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
606 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
607 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
608
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
609 (let (selected)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
611 ;; 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
612 ;; 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
613
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
614 (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
615 (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
616
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
617 ;; 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
618 (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
619 (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
620 (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
621
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
622 ;; 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
623 (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
624 (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
625
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
626 (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
627 (first-choice (concat
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
628 (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
629 ada-project-file-extension))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
630 (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
631
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
632 ;; 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
633 ;; 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
634 (parse-sexp-lookup-properties nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
635 (prj-files (directory-files
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
636 dir t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
637 (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
638 (choice nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
639 (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
640
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
641 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
642
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
643 ;; 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
644 (default
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
645 (set 'selected (cdr default)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
646
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
647 ;; 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
648 ((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
649 (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
650 (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
651
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
652 ;; 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
653 ;; but not the same extension.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
654 ((file-exists-p first-choice)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
655 (set 'selected first-choice))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
656
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
657 ;; 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
658 ((= (length prj-files) 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
659 (set 'selected (car prj-files)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
660
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
661 ;; 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
662 ((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
663 (save-window-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
664 (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
665 (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
666 (princ "be used ?\n\n")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
667 (princ " no. file name \n")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
668 (princ " --- ------------------------\n")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
669 (let ((counter 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
670 (while (<= counter (length prj-files))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
671 (princ (format " %2d) %s\n"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
672 counter
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
673 (nth (1- counter) prj-files)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
674 (setq counter (1+ counter))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
675 ))) ; end of with-output-to ...
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
676 (setq choice nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
677 (while (or
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
678 (not choice)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
679 (not (integerp choice))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
680 (< choice 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
681 (> choice (length prj-files)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
682 (setq choice (string-to-int
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
683 (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
684 (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
685
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
686 ;; 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
687 ;; 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
688 ((= (length prj-files) 0)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
689 (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
690 (setq ada-last-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
691 (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
692 (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
693 (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
694 ))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
695 selected
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
696 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 (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
700 "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
701 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
702 (if prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
703 (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
704 (ada-buffer (current-buffer)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
705 (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
706
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
707 ;; 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
708 (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
709
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
710 ;; 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
711 ;; 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
712 ;; 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
713 ;; 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
714
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
715 (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
716
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
717 (widen)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
718 (goto-char (point-min))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
719
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
720 ;; 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
721 (while (not (eobp))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
722 (if (looking-at "^\\([^=]+\\)=\\(.*\\)")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
723 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
724 ((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
725 (add-to-list 'src_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) "obj_dir")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
728 (add-to-list 'obj_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
729 (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
730 ((string= (match-string 1) "casing")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
731 (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
732 ((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
733 (set 'project
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
734 (plist-put project 'build_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
735 (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
736 (t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
737 (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
738 (match-string 2))))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
739 (forward-line 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
740
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
741 (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
742 (reverse src_dir))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
743 (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
744 (reverse obj_dir))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
745 (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
746
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
747 ;; 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
748 (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
749 (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
750 (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
751
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
752 ;; 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
753 ;; 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
754 (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
755 (plist-get project 'src_dir)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
756 (plist-get project 'build_dir)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
757
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
758 ;; 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
759 (mapcar (lambda (x)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
760 (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
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 (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
763 (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
764 ada-xref-default-prj-file))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
765 compilation-search-path)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
766
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
767 ;; 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
768 ;; 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
769 (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
770 (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
771 ada-search-directories))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
772
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
773 ;; Kill the .ali buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
774 (kill-buffer nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
775 (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
776
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
777 ;; 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
778 (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
779
30408
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 ))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
782
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
783
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 (defun ada-find-references (&optional pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
785 "Find all references to the entity under POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
786 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
787 (interactive "")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788 (unless pos
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 (set 'pos (point)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792 (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
793 (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
794 (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
795
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
796 (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
797
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798 ;; 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
799 (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
800 (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
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 nil nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
804 (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
805 (ada-file-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
806 (ada-line-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
807 (ada-column-of identlist))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
808 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
809
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810 (defun ada-find-any-references (entity &optional file line column)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
811 "Search for references to any entity whose name is ENTITY.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
812 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
813 (interactive "sEntity name: ")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
814 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816 (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
817 (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
818 (if line (concat ":" line))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 (if column (concat ":" column)))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
820
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821 ;; 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
822 (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
823 (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
824
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
825 (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
826
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
827 ;; Hide the "Compilation" menu
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
829 (set-buffer "*gnatfind*")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830 (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
831 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
833
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 (defun ada-buffer-list ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
835 "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
836 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 (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
839 (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
840 (erase-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841 (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
842 (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
843 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
844 (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
845 (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
846 (princ "\n
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847 Buffer Mode Project file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848 ------ ---- ------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 \n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 (let ((bl (buffer-list)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851 (while bl
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 (let* ((buffer (car bl))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 (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
854 this-buffer-mode-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 this-buffer-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 (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
859 (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
860 "Buffer Menu" mode-name))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 (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
862 "Ada")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 (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
864 (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
865 (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 (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
867 ""))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 (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
869 "Ada")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 (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
872 (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
873 (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
874 (princ "\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 ))
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 (setq bl (cdr bl))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 ) ;; end while
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 );; end let
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 ) ;; end save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 (display-buffer "*Buffer List*")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 (other-window 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 (defun ada-change-prj (filename)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
886 "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
887 (interactive "fproject file:")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 ;; 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
890 (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
891 (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
892
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
893 (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
894 (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
895 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 (defun ada-change-default-prj (filename)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
898 "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
899 (interactive "ffile name:")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
900 (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
901 (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
902
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
903 ;; 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
904 (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
905 (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
906 (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
907
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908 ;; Reparse the project file
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
909 (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
910
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912 ;; ----- Identlist manipulation -------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 ;; 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
914 ;; 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
915
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 (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
917 (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
918 (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
919 (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
920 (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
921 (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
922 (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
923 (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
924 (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
925
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926 (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
927 (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
928 (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
929 (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
930 (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
931 (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
932 (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
933 (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
934
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
935 (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
936 "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
937 (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
938
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
939
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
940
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
941 ;; ----- Identifier Completion --------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
942 (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
943 "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
944 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
945 option."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
946 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
947 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
948
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
949 ;; 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
950 ;; 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
951 (let* ((curbuf (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
952 (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
953 (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
954 (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
955 "[a-zA-Z0-9_]*\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
956 (completed nil)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
957 (symalist nil))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
958
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
959 ;; Open the .ali file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
960 (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
961 (goto-char (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
962
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
963 ;; 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
964 (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
965 (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
966
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
967 (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
968
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
969 ;; kills .ali buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
970 (kill-buffer nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
971
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
972 ;; 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
973 (set-buffer curbuf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
974 (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
975 (replace-match "")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
976 ;; inserts the completed symbol
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
977 (insert completed)
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
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
980 ;; ----- Cross-referencing ----------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
981
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
982 (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
983 "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
984 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
985 (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
986 (ada-goto-declaration (point)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
987
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
988 (defun ada-goto-declaration (pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
989 "Display the declaration of the identifier around POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
990 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
991 non-nil."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
992 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
993 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
994 (push-mark pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
995 (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
996 (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
997
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
998 (defun ada-goto-declaration-other-frame (pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
999 "Display the declaration of the identifier around POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1000 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
1001 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1002 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1003 (push-mark pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1004 (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
1005 (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
1006
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1007 (defun ada-remote (command)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1008 "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
1009 (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
1010 (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
1011 command
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1012 (format "%s %s '(%s)'"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1013 remote-shell-program
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1014 machine
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1015 command))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1016
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1017 (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
1018 "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
1019 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
1020 (if (= (string-to-char dir) ?/)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1021 dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1022 (concat root-dir dir)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1023
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1024 (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
1025 "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
1026 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
1027 front."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1028 (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
1029
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1030 (defun ada-set-environment ()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1031 "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
1032 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
1033 project file."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1034 (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
1035 (objects (getenv "ADA_OBJECTS_PATH"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1036 (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
1037 (if include
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1038 (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
1039 (if objects
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1040 (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
1041 (cons
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1042 (concat "ADA_INCLUDE_PATH="
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1043 include
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1044 (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
1045 (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
1046 path-separator))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1047 (cons
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1048 (concat "ADA_OBJECTS_PATH="
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1049 objects
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1050 (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
1051 (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
1052 path-separator))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1053 process-environment))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1054
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1055 (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
1056 "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
1057 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
1058 (interactive "P")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1059 (ada-require-project-file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1060 (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
1061 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1062 (compilation-scroll-output t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1063
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1064 (set 'compilation-search-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1065 (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
1066 (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
1067
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1068 ;; 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
1069 (unless cmd
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1070 (setq cmd "" arg t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1071
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1072 (compile (ada-remote
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1073 (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
1074 (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
1075 cmd)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1076 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1077
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1078 (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
1079 "Recompile the current file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1080 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
1081 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
1082 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
1083 (interactive "P")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1084 (ada-require-project-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1085 (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
1086 (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
1087 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1088 (compilation-scroll-output t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1089
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1090 (set 'compilation-search-path
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1091 (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
1092 (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
1093
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1094 ;; 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
1095 (if cmd
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1096 (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
1097 (setq cmd "" arg t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1098
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1099 (compile (ada-remote
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1100 (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
1101 (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
1102 cmd)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1103
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1104 (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
1105 "Recompile the current file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1106 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
1107 (interactive "P")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1108 (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
1109
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1110 (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
1111 "Run the application.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1112 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
1113 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1114 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1115
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1116 (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
1117 (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
1118 (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
1119
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1120 (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
1121
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1122 ;; 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
1123 (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
1124 (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
1125
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1126 ;; 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
1127 (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
1128 (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
1129
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1130 ;; 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
1131 (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
1132
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1133 ;; Run the command
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1134 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1135 (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
1136 (set 'buffer-read-only nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1137 (erase-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1138 (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
1139 (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
1140 (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
1141 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1142 (display-buffer "*run*")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1143
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1144 ;; 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
1145 (other-window 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1146 (switch-to-buffer "*run*")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1147 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1148
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1149
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1150 (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
1151 "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
1152 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
1153 (interactive "P")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1154 (let ((buffer (current-buffer))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1155 gdb-buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1156 cmd)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1157 (ada-require-project-file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1158 (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
1159 (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
1160 (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
1161 (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
1162
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1163 ;; 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
1164 (if (not cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1165 (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
1166 " "
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1167 (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
1168 (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
1169 (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
1170
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1171 ;; 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
1172 ;; 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
1173 (if ada-prj-prj-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1174 (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
1175
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1176 (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
1177 (boundp 'jdb))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1178 (funcall (symbol-function 'jdb) cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1179 (gdb cmd))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1180
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1181 (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
1182
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1183 ;; 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
1184 ;; 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
1185 (switch-to-buffer buffer)
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 (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
1188 (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
1189
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1190 ;; 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
1191 ;; 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
1192 ;; 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
1193 ;; 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
1194 (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
1195 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1196
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1197
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1198 (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
1199 "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
1200 with the current buffer.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1201 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
1202 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
1203 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
1204 (interactive "P")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1205 (if filename
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1206 (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
1207 (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
1208 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1209
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1210
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1211 ;; ------ Private routines
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1212
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1213 (defun ada-xref-current (file &optional ali-file-name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1214 "Update the cross-references for FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1215 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
1216 ;; kill old buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1217 (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
1218 (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
1219 (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
1220 ;; read the project file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1221 (ada-require-project-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1222 (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
1223 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1224 (compilation-scroll-output t)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1225 (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
1226 (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
1227
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1228 ;; 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
1229 (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
1230
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1231 ;; prompt for command to execute
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1232 (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
1233 (compile (ada-remote
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1234 (if ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1235 (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
1236 cmd)))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1237
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1238 (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
1239 "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
1240 (let (found)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1241 (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
1242 (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
1243 (file-name-nondirectory file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1244
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1245 (unless (file-exists-p found)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1246 (set 'found nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1247 (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
1248 found))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1249
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1250 (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
1251 "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
1252 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
1253 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
1254 (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
1255 (append
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 ;; 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
1258 (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
1259
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1260 (ada-get-absolute-dir-list
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1261 (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
1262 (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
1263
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1264 ;; 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
1265 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
1266
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1267 (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
1268 "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
1269 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
1270 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
1271 (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
1272 (append
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 ;; 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
1275 (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
1276
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1277 (ada-get-absolute-dir-list
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1278 (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
1279 (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
1280
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1281 ;; 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
1282 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
1283
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1284
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1285 (defun ada-get-ali-file-name (file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1286 "Create the ali file name for the ada-file FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1287 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
1288 the project file."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1289
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1290 ;; 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
1291 ;; 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
1292 ;; 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
1293 ;; 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
1294 ;; 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
1295 ;; 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
1296 ;; 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
1297 ;; .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
1298 ;; 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
1299 ;; 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
1300 ;; 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
1301
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1302 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1303 (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
1304 (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
1305 (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
1306 ".ali"))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1307 ali-file-name)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1308 ;; First step
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1309 ;; 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
1310 (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
1311
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1312 ;; 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
1313 ;; 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
1314 ;; 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
1315 (unless ali-file-name
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1316 (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
1317 (let ((is-spec nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1318 (specs ada-spec-suffixes)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1319 body-ali)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1320 (while specs
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1321 (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
1322 file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1323 (set 'is-spec t))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1324 (set 'specs (cdr specs)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1325
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1326 (if is-spec
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1327 (set 'body-ali
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1328 (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
1329 (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
1330 (file-name-nondirectory
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1331 (ada-other-file-name)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1332 ".ali"))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1333 (if body-ali
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1334 (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
1335
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1336 ;; 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
1337 ;; 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
1338 ;; 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
1339 ;; 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
1340 (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
1341 (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
1342 (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
1343 ".ali"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1344 (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
1345
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1346 ;; 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
1347 (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
1348 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1349 ;; 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
1350 (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
1351 (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
1352 (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
1353 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1354
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1355 ;; 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
1356 (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
1357 ada-xref-create-ali)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1358 (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
1359
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1360 ;; 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
1361 (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
1362 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1363
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1364 (defun ada-get-ada-file-name (file original-file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1365 "Create the complete file name (+directory) for FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1366 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
1367 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
1368
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1369 (save-excursion
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1370
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1371 ;; 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
1372 ;; 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
1373 (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
1374 (if buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1375 (set-buffer buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1376 (find-file original-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1377 (ada-require-project-file)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1378
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1379 ;; 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
1380 ;; 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
1381 (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
1382 (if filename
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1383 (expand-file-name filename)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1384 (error (concat
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1385 (file-name-nondirectory file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1386 " 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
1387
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1388 )))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1389
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1390 (defun ada-find-file-number-in-ali (file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1391 "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
1392 (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
1393 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1394
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1395 (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
1396 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1397 (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
1398 (count-lines begin (point))))
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 (defun ada-read-identifier (pos)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1401 "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
1402
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1403 ;; 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
1404 ;; .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
1405 (if compilation-in-progress
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1406 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1407 (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
1408 (set 'quit-flag t)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1409
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1410 ;; 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
1411 (if (>= (point) (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1412 (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
1413
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1414 ;; 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
1415 ;; 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
1416 (goto-char pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1417 (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
1418
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1419 ;; 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
1420 (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
1421 (error "Inside comment"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1422
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1423 (let (identifier identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1424 ;; 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
1425 ;; as in "+", "-", ..
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1426 (if (= (char-after) ?\")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1427 (forward-char 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1428
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1429 ;; 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
1430 ;; This is only true if:
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1431 ;; - the symbol is +, -, ...
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1432 ;; - 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
1433 (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
1434 (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
1435 (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
1436 (= (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
1437 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1438 (if (and (= (char-before) ?\")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1439 (= (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
1440 (forward-char -1))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1441 (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
1442
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1443 (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
1444 (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
1445 (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
1446 (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
1447 (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
1448 (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
1449 (error "No identifier around")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1450
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1451 ;; Build the identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1452 (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
1453 (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
1454 (ada-set-line identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1455 (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
1456 (ada-set-column identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1457 (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
1458 (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
1459 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1460 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1461
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1462 (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
1463 "Completes and returns IDENTLIST with the information extracted
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1464 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
1465
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1466 (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
1467 declaration-found)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1468 (set-buffer ali-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1469 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1470 (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
1471
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1472 ;; 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
1473 ;; 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
1474 ;; 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
1475
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1476 (if (re-search-forward
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1477 (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
1478 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1479 (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
1480 (set 'declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1481 (re-search-forward
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1482 (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
1483 "." (ada-column-of identlist)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1484 "[ *]" (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
1485 " \\(.*\\)$") bound t))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1486 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1487 (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
1488 ))
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 ;; 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
1491 ;; 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
1492
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1493 (unless declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1494
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1495 ;; 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
1496 ;; reference to it
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1497 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1498 (set 'declaration-found t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1499 (ada-set-ali-index
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1500 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1501 (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
1502 (ada-file-of identlist))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1503 (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
1504 "|\\([0-9]+.[0-9]+ \\)*"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1505 (ada-line-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1506 "[^0-9]"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1507 (ada-column-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1508 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1509
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1510 ;; 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
1511 ;; 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
1512 ;; 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
1513 (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
1514 (ada-line-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1515 "[^0-9]"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1516 (ada-column-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1517 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1518
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1519 ;; 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
1520 ;; 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
1521 ;; created
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1522 (set 'declaration-found nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1523 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1524 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1525
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1526 ;; 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
1527 ;; 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
1528 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1529 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1530 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1531 ;; 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
1532 (while (looking-at "^\\.")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1533 (previous-line 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1534 (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
1535 (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
1536 (set 'declaration-found nil))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1537
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1538 ;; 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
1539 ;; 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
1540 ;; 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
1541 ;; automatically
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1542 (unless declaration-found
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1543 (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
1544 (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
1545 ;; 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
1546 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1547 (kill-buffer ali-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1548 (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
1549 " found."))
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 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1552
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1553
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1554 ;; 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
1555 ;; information available
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1556 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1557 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1558 (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
1559 (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
1560 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1561 (next-line 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1562 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1563 (while (looking-at "^\\.\\(.*\\)")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1564 (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
1565 (next-line 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1566 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1567
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1568 (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
1569 (ada-set-declare-file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1570 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1571 (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
1572 (ada-file-of identlist))))
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 (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
1575 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1576 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1577
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1578 (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
1579 "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
1580 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
1581 to make some guesses.
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1582 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
1583
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1584 (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
1585 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1586 (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
1587 (my-regexp (concat "[ *]"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1588 (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
1589 (line-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1590 (col-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1591 (line-ali 0)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1592 (len 0)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1593 (choice 0)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1594 (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
1595
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1596 (goto-char (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1597 (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
1598 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1599 (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
1600 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1601 ;; 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
1602 (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
1603 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1604 (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
1605 (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
1606 (setq line-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1607 (setq col-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1608 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1609 ;; 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
1610 (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
1611 (add-to-list
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1612 '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
1613 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1614 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1615 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1616
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1617 ;; 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
1618 (setq len (length declist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1619 (cond
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1620 ;; none => error
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1621 ((= len 0)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1622 (kill-buffer (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1623 (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
1624 (ada-name-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1625 " recorded in .ali file")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1626
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1627 ;; 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
1628 ((= len 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1629 (goto-line (caar declist)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1630
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1631 ;; 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
1632 (t
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1633 (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
1634
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1635 (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
1636 (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
1637 (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
1638 (princ " --- --------------------- ---- ----\n")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1639 (let ((counter 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1640 (while (<= counter len)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1641 (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
1642 counter
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1643 (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
1644 (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
1645 (ada-file-of identlist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1646 (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
1647 (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
1648 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1649 (setq counter (1+ counter))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1650 ) ; end of while
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1651 ) ; end of let
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1652 ) ; 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
1653 (setq choice nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1654 (while (or
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1655 (not choice)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1656 (not (integerp choice))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1657 (< choice 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1658 (> choice len))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1659 (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
1660 (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
1661 (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
1662 (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
1663 ))))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1664
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1665
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1666 (defun ada-find-in-ali (identlist &optional other-frame)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1667 "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
1668 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
1669 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
1670
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1671 (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
1672 (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
1673 file line col)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1674
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1675 ;; 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
1676 (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
1677 (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
1678 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1679 (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
1680 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
1681 ;; 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
1682 (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
1683 (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
1684 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1685 (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
1686 (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
1687 (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
1688 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1689 ;; 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
1690 (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
1691 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1692 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1693 (error "No body found"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1694
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1695 ;; 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
1696 (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
1697 (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
1698 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
1699 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
1700 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1701
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1702 ;; 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
1703 (ada-xref-change-buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1704 (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
1705 (string-to-number line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1706 (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
1707 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1708 other-frame)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1709 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1710
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1711 (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
1712 (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
1713 "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
1714 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
1715 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
1716 match. Kills the .ali buffer at the end.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1717 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
1718
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1719 (let (prj-file
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1720 declaration-buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1721 (ali-buffer (current-buffer)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1722
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1723 ;; 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
1724 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1725 (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
1726 (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
1727
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1728 ;; 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
1729 (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
1730 (if other-frame
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1731 (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
1732 (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
1733 (set-buffer declaration-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1734 (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
1735 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1736 (find-file file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1737 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1738
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1739 ;; 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
1740 (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
1741 (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
1742
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1743 ;; 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
1744 (push-mark)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1745 (goto-line line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1746 (move-to-column column)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1747
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1748 ;; 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
1749 ;; 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
1750 ;; 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
1751 (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
1752 (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
1753
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1754 (kill-buffer ali-buffer)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1755
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1756
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1757 (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
1758 "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
1759 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
1760 (let ((orgpos (point))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1761 (newpos nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1762 (diff nil))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1763
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1764 (goto-char (point-max))
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 ;; 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
1767 (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
1768
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1769 ;; 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
1770 (if (and
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1771 (not (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1772 (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
1773 (looking-at "_")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1774 (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
1775 (or
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1776 ;; variable declaration ?
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1777 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1778 (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
1779 (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
1780 (looking-at ":[^=]"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1781 ;; 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
1782 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1783 (ada-goto-previous-word)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1784 (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
1785
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1786 ;; 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
1787 (if (or (not diff)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1788 (< (abs (- (point) orgpos)) diff))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1789 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1790 (setq newpos (point)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1791 diff (abs (- newpos orgpos))))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1792 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1793
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1794 (if newpos
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1795 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1796 (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
1797 (goto-char newpos))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1798 nil)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1799
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1800
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1801 ;; 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
1802 (defun ada-goto-parent ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1803 "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
1804 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1805 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1806
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1807 (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
1808 (unit-name nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1809 (body-name nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1810 (ali-name nil))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1811 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1812 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1813 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1814 (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
1815 (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
1816 (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
1817 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1818 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1819 (error "No parent unit !"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1820 (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
1821 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1822
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1823 ;; 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
1824 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1825 (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
1826 "%s[ \t]+\\([^ \t]+\\)[ \t]+"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1827 "\\([^ \t\n]+\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1828 (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
1829 (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
1830 (kill-buffer buffer)
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
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1833 (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
1834
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1835 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1836 ;; 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
1837 (if ali-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1838 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1839 (find-file ali-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1840 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1841 (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
1842 "\\([^ \t]+\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1843 (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
1844 (kill-buffer (current-buffer))
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 )
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 (find-file body-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1850 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1851
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1852 (defun ada-make-filename-from-adaname (adaname)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1853 "Determine the filename in which ADANAME is found.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1854 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
1855 (let (krunch-buf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1856 (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
1857 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1858 (set-buffer krunch-buf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1859 ;; 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
1860 (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
1861 adaname ada-krunch-args)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1862 ;; 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
1863 (setq adaname (buffer-substring
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1864 (point-min)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1865 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1866 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1867 (end-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1868 (point))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1869 (kill-buffer krunch-buf)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1870 adaname
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1871 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1872
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1873 (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
1874 "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
1875 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
1876 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
1877 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1878
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1879 (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
1880
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1881 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1882
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1883 (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
1884
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1885 ;; 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
1886 (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
1887 (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
1888 (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
1889 (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
1890 (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
1891
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1892 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1893 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1894 (compilation-minor-mode 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1895 (erase-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1896 (insert gnatstub-cmd)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1897 (newline)
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 ;; 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
1900 (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
1901
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1902 (if (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1903 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1904 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1905 (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
1906 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1907 (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
1908 (sleep-for 2)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1909 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1910 (ada-make-body))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1911
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1912 ;; 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
1913
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1914 ;; 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
1915 (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
1916 (kill-buffer (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1917
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1918 (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
1919 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1920 (find-file output)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1921 (kill-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 ;; display the error buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1924 (display-buffer buffer)
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 )))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1927
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1928
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1929 (defun ada-xref-initialize ()
38441
ceb40bd97a77 (ada-xref-initialize): Fix call to add-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
1930 "Function called by `ada-mode-hook' to initialize the ada-xref.el package.
ceb40bd97a77 (ada-xref-initialize): Fix call to add-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
1931 For instance, it creates the gnat-specific menus, sets some hooks for
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1932 find-file...."
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1933 (make-local-hook 'ff-file-created-hooks)
38441
ceb40bd97a77 (ada-xref-initialize): Fix call to add-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
1934 ;; This should really be an `add-hook'. -stef
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1935 (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
1936
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1937 ;; 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
1938 ;; 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
1939 (make-local-hook 'ff-pre-find-hooks)
38441
ceb40bd97a77 (ada-xref-initialize): Fix call to add-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
1940 (add-hook 'ff-pre-find-hooks 'ada-require-project-file nil t)
25899
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 ;; 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
1943 (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
1944 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1945
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1946
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1947 ;; ----- 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
1948
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1949 ;; 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
1950 ;; 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
1951 (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
1952 (ada-add-keymap)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1953
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1954 (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
1955
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1956 ;; 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
1957 (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
1958 (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
1959
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1960 ;; 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
1961 (ada-initialize-runtime-library)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1962
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1963 ;; 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
1964 (set 'ada-search-directories
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1965 (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
1966 ada-search-directories))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1967
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1968 ;; 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
1969 ;; 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
1970 ;; 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
1971 (add-hook 'ada-mode-hook
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1972 (lambda()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1973 (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
1974 (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
1975
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1976 (provide 'ada-xref)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1977
32301
0f1f7e931493 Fix header line, copyright notice.
Dave Love <fx@gnu.org>
parents: 30408
diff changeset
1978 ;;; ada-xref.el ends here