annotate lisp/progmodes/ada-xref.el @ 50056:7933b5de384c

* xterm.c (handle_one_xevent): Pass ReparentNotify to Xt even if the event isn't for a frame (i.e. for dialogs).
author Jan Djärv <jan.h.d@swipnet.se>
date Sat, 08 Mar 2003 10:16:04 +0000
parents 0d8b17d428b5
children f6a0822e108d d7ddb3e565de
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
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
3 ;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 2001, 2002
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
4 ;; 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
5
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; 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
7 ;; 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
8 ;; 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
9 ;; Maintainer: Emmanuel Briot <briot@gnat.com>
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
10 ;; Ada Core Technologies's version: Revision: 1.155.2.8 (GNAT 3.15)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; Keywords: languages ada xref
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12
38361
d42c9135a92d Say that the file _is_ part of Emacs.
Eli Zaretskii <eliz@gnu.org>
parents: 32301
diff changeset
13 ;; 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
14
38401
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
15 ;; 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
16 ;; 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
17 ;; 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
18 ;; any later version.
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
38401
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
20 ;; 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
21 ;; 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
22 ;; 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
23 ;; 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
24
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; 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
26 ;; 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
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
64d8d90d180d Fix license commentary.
Gerd Moellmann <gerd@gnu.org>
parents: 38361
diff changeset
28 ;; 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
29
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;;; Commentary:
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;;; 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
32 ;;; 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
33 ;;; 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
34 ;;;
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;;; 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
36 ;;; 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
37 ;;; 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
38
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;;; 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
40
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38401
diff changeset
41 ;;; Code:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38401
diff changeset
42
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; ----- Requirements -----------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (require 'compile)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 (require 'comint)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; ------ Use variables
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (defcustom ada-xref-other-buffer t
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
50 "*If nil, always display the cross-references in the same buffer.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
51 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
52 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
54 (defcustom ada-xref-create-ali nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
55 "*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
56 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
57 :type 'boolean :group 'ada)
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 (defcustom ada-xref-confirm-compile nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
60 "*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
61 the application."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 :type 'boolean :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 (defcustom ada-krunch-args "0"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
65 "*Maximum number of characters for filenames created by gnatkr.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
66 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
67 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
69 (defcustom ada-prj-default-comp-opt "-gnatq -gnatQ"
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
70 "Default compilation options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
71 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
72
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
73 (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
74 "Default binder options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
75 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
76
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
77 (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
78 "Default linker options."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
79 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
80
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
81 (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
82 "Default options for gnatmake."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
83 :type 'string :group 'ada)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
84
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
85 (defcustom ada-prj-gnatfind-switches "-rf"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
86 "Default switches to use for gnatfind.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
87 You should modify this variable, for instance to add -a, if you are working
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
88 in an environment where most ALI files are write-protected.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
89 The command gnatfind is used every time you choose the menu
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
90 \"Show all references\"."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
91 :type 'string :group 'ada)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
92
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
93 (defcustom ada-prj-default-comp-cmd
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
94 (concat "${cross_prefix}gnatmake -u -c ${gnatmake_opt} ${full_current} -cargs"
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
95 " ${comp_opt}")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 "*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
97 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
98 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
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-debugger "${cross_prefix}gdb"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
102 "*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
103 `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
104 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (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
107 (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
108 "-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
109 "*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
110 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
111 :type 'string :group 'ada)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 (defcustom ada-prj-default-project-file ""
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
114 "*Name of the project file to use for every Ada file.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
115 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
116 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
117 :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
118
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (defcustom ada-gnatstub-opts "-q -I${src_dir}"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
120 "*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
121 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
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-always-ask-project nil
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
125 "*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
126 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
127 :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
128
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
129 (defconst is-windows (memq system-type (quote (windows-nt)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
130 "True if we are running on windows NT or windows 95.")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
131
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
132 (defcustom ada-tight-gvd-integration nil
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
133 "*If non-nil, a new Emacs frame will be swallowed in GVD when debugging.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
134 If GVD is not the debugger used, nothing happens.")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
135
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
136 (defcustom ada-xref-search-with-egrep t
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
137 "*If non-nil, use egrep to find the possible declarations for an entity.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
138 This alternate method is used when the exact location was not found in the
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
139 information provided by GNAT. However, it might be expensive if you have a lot
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
140 of sources, since it will search in all the files in your project."
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
141 :type 'boolean :group 'ada)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
142
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
143 (defvar ada-load-project-hook nil
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
144 "Hook that is run when loading a project file.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
145 Each function in this hook takes one argument FILENAME, that is the name of
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
146 the project file to load.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
147 This hook should be used to support new formats for the project files.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
148
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
149 If the function can load the file with the given filename, it should create a
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
150 buffer that contains a conversion of the file to the standard format of the
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
151 project files, and return that buffer. (the usual \"src_dir=\" or \"obj_dir=\"
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
152 lines). It should return nil if it doesn't know how to convert that project
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
153 file.")
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
154
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
155
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 ;; ------- 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
157 (defvar ada-last-prj-file ""
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
158 "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
159
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
160 (defvar ada-check-switch "-gnats"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
161 "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
162
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
163 (defconst ada-project-file-extension ".adp"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
164 "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
165
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
166 (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
167 "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
168 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
169
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
170 (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
171 "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
172 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
173
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (defvar ada-xref-pos-ring '()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
175 "List of positions selected by the cross-references functions.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
176 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
177
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
178 (defvar ada-cd-command
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
179 (if (string-match "cmdproxy.exe" shell-file-name)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
180 "cd /d"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
181 "cd")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
182 "Command to use to change to a specific directory. On windows systems
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
183 using cmdproxy.exe as the shell, we need to use /d or the drive is never
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
184 changed.")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
185
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
186 (defvar ada-command-separator (if is-windows " && " "\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
187 "Separator to use when sending multiple commands to `compile' or
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
188 `start-process'.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
189 cmdproxy.exe doesn't recognize multiple-line commands, so we have to use
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
190 \"&&\" for now.")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
191
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 (defconst ada-xref-pos-ring-max 16
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
193 "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
194
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (defvar ada-operator-re
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
196 "\\+\\|-\\|/\\|\\*\\*\\|\\*\\|=\\|&\\|abs\\|mod\\|rem\\|and\\|not\\|or\\|xor\\|<=\\|<\\|>=\\|>"
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
197 "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
198
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
199 (defvar ada-xref-project-files '()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
200 "Associative list of project files.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
201 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
202 \((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
203 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
204
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
205 (defun ada-quote-cmd (cmd)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
206 "Duplicates all \\ characters in CMD so that it can be passed to `compile'"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
207 (mapconcat 'identity (split-string cmd "\\\\") "\\\\"))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
208
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
209 (defun ada-initialize-runtime-library (cross-prefix)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
210 "Initializes the variables for the runtime library location.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
211 CROSS-PREFIX is the prefix to use for the gnatls command"
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
212 (save-excursion
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
213 (setq ada-xref-runtime-library-specs-path '()
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
214 ada-xref-runtime-library-ali-path '())
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
215 (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
216 (widen)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
217 (erase-buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
218 ;; 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
219 (condition-case nil
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
220 ;; 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
221 (unwind-protect
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
222 (progn
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
223 (call-process (concat cross-prefix "gnatls")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
224 nil t nil "-v")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
225 (goto-char (point-min))
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 ;; Source path
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
228
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
229 (search-forward "Source Search Path:")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
230 (forward-line 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
231 (while (not (looking-at "^$"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
232 (back-to-indentation)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
233 (unless (looking-at "<Current_Directory>")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
234 (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
235 (buffer-substring-no-properties
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
236 (point)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
237 (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
238 (forward-line 1))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
239
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
240 ;; Object path
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
241
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
242 (search-forward "Object Search Path:")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
243 (forward-line 1)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
244 (while (not (looking-at "^$"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
245 (back-to-indentation)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
246 (unless (looking-at "<Current_Directory>")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
247 (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
248 (buffer-substring-no-properties
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
249 (point)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
250 (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
251 (forward-line 1))
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 (kill-buffer nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
254 (error nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
255 (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
256 (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
257 (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
258 (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
259 ))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
260
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
261
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
262 (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
263 "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
264 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
265 As a special case, ${current} is replaced with the name of the currently
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
266 edited file, minus extension but with directory, and ${full_current} is
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
267 replaced by the name including the extension."
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
268
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
269 (while (string-match "\\(-[^-\$IO]*[IO]\\)?\${\\([^}]+\\)}" cmd-string)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
270 (let (value
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
271 (name (match-string 2 cmd-string)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
272 (cond
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
273 ((string= name "current")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
274 (setq value (file-name-sans-extension (buffer-file-name))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
275 ((string= name "full_current")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
276 (setq value (buffer-file-name)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
277 (t
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
278 (save-match-data
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
279 (setq value (ada-xref-get-project-field (intern name))))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
280
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
281 ;; Check if there is an environment variable with the same name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
282 (if (null value)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
283 (if (not (setq value (getenv name)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
284 (message (concat "No environment variable " name " found"))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
285
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
286 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
287 ((null value)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
288 (setq cmd-string (replace-match "" t t cmd-string)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
289 ((stringp value)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
290 (setq cmd-string (replace-match value t t cmd-string)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
291 ((listp value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
292 (let ((prefix (match-string 1 cmd-string)))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
293 (setq cmd-string (replace-match
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
294 (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
295 t t cmd-string)))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
296 ))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
297 cmd-string)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
298
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
299 (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
300 "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
301
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
302 (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
303 plist)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
304 (save-excursion
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
305 (set-buffer ada-buffer)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
306
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
307 (set 'plist
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
308 ;; 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
309 ;; 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
310 ;; Ada file or not even associated with a file
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
311 (list 'filename (expand-file-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
312 (cond
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
313 (ada-prj-default-project-file
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
314 ada-prj-default-project-file)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
315 (file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
316 (ada-prj-get-prj-dir file))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
317 (t
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
318 (message (concat "Not editing an Ada file,"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
319 "and no default project "
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
320 "file specified!"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
321 "")))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
322 '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
323 'src_dir (list ".")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
324 'obj_dir (list ".")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
325 '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
326 ada-case-exception-file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
327 (list ada-case-exception-file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
328 '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
329 '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
330 '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
331 'gnatmake_opt ada-prj-default-gnatmake-opt
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
332 'gnatfind_opt ada-prj-gnatfind-switches
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
333 'main (if file
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
334 (file-name-nondirectory
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
335 (file-name-sans-extension file))
30408
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 'main_unit (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
338 (file-name-nondirectory
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
339 (file-name-sans-extension file))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
340 "")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
341 'cross_prefix ""
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
342 'remote_machine ""
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
343 'comp_cmd (list (concat ada-cd-command " ${build_dir}")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
344 ada-prj-default-comp-cmd)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
345 'check_cmd (list (concat ada-prj-default-comp-cmd " "
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
346 ada-check-switch))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
347 'make_cmd (list (concat ada-cd-command " ${build_dir}")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
348 ada-prj-default-make-cmd)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
349 'run_cmd (list (concat ada-cd-command " ${build_dir}")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
350 (concat "${main}"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
351 (if is-windows ".exe")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
352 'debug_pre_cmd (list (concat ada-cd-command
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
353 " ${build_dir}"))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
354 '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
355 (if is-windows " ${main}.exe"
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
356 " ${main}"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
357 'debug_post_cmd (list nil)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
358 )
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
359 (set symbol plist)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
360
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
361 (defun ada-xref-get-project-field (field)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
362 "Extract the value of FIELD from the current project file.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
363 The project file must have been loaded first.
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
364 A default value is returned if the file was not found.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
365
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
366 Note that for src_dir and obj_dir, you should rather use
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
367 `ada-xref-get-src-dir-field' or `ada-xref-get-obj-dir-field' which will in
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
368 addition return the default paths."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
369
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
370 (let ((file-name ada-prj-default-project-file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
371 file value)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
372
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
373 ;; Get the project file (either the current one, or a default one)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
374 (setq file (or (assoc file-name ada-xref-project-files)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
375 (assoc nil ada-xref-project-files)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
376
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
377 ;; 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
378 (if file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
379 ;; 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
380 (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
381
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
382 ;; 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
383 (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
384 (add-to-list 'ada-xref-project-files (cons nil value))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
385 (ada-xref-update-project-menu)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
386 (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
387 )
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
388
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
389 ;; Substitute the ${...} constructs in all the strings, including
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
390 ;; inside lists
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
391 (cond
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
392 ((stringp value)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
393 (ada-treat-cmd-string value))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
394 ((null value)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
395 nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
396 ((listp value)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
397 (mapcar (lambda(x) (if x (ada-treat-cmd-string x) x)) value))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
398 (t
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
399 value)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
400 )
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
401 ))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
402
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
403
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
404 (defun ada-xref-get-src-dir-field ()
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
405 "Return the full value for src_dir, including the default directories.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
406 All the directories are returned as absolute directories."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
407
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
408 (let ((build-dir (ada-xref-get-project-field 'build_dir)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
409 (append
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
410 ;; Add ${build_dir} in front of the path
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
411 (list build-dir)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
412
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
413 (ada-get-absolute-dir-list (ada-xref-get-project-field 'src_dir)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
414 build-dir)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
415
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
416 ;; Add the standard runtime at the end
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
417 ada-xref-runtime-library-specs-path)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
418
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
419 (defun ada-xref-get-obj-dir-field ()
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
420 "Return the full value for obj_dir, including the default directories.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
421 All the directories are returned as absolute directories."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
422
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
423 (let ((build-dir (ada-xref-get-project-field 'build_dir)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
424 (append
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
425 ;; Add ${build_dir} in front of the path
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
426 (list build-dir)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
427
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
428 (ada-get-absolute-dir-list (ada-xref-get-project-field 'obj_dir)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
429 build-dir)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
430
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
431 ;; Add the standard runtime at the end
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
432 ada-xref-runtime-library-ali-path)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
433
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
434 (defun ada-xref-update-project-menu ()
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
435 "Update the menu Ada->Project, with the list of available project files."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
436 (interactive)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
437 (let (submenu)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
438
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
439 ;; Create the standard items
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
440 (set 'submenu (list (cons 'Load (cons "Load..."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
441 'ada-set-default-project-file))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
442 (cons 'New (cons "New..." 'ada-prj-new))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
443 (cons 'Edit (cons "Edit..." 'ada-prj-edit))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
444 (cons 'sep (cons "---" nil))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
445
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
446 ;; Add the new items
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
447 (mapcar
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
448 (lambda (x)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
449 (let ((name (or (car x) "<default>"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
450 (command `(lambda ()
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
451 "Change the active project file."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
452 (interactive)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
453 (ada-parse-prj-file ,(car x))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
454 (set 'ada-prj-default-project-file ,(car x))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
455 (ada-xref-update-project-menu))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
456 (set 'submenu
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
457 (append submenu
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
458 (list (cons (intern name)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
459 (list
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
460 'menu-item
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
461 (if (string= (file-name-extension name)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
462 ada-project-file-extension)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
463 (file-name-sans-extension
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
464 (file-name-nondirectory name))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
465 (file-name-nondirectory name))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
466 command
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
467 :button (cons
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
468 :toggle
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
469 (equal ada-prj-default-project-file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
470 (car x))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
471 ))))))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
472
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
473 ;; Parses all the known project files, and insert at least the default
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
474 ;; one (in case ada-xref-project-files is nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
475 (or ada-xref-project-files '(nil)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
476
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
477 (if (not ada-xemacs)
47745
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
478 (if (and (lookup-key ada-mode-map [menu-bar Ada])
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
479 (lookup-key ada-mode-map [menu-bar Ada Project]))
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
480 (setcdr (lookup-key ada-mode-map [menu-bar Ada Project])
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
481 submenu)
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
482 (if (lookup-key ada-mode-map [menu-bar ada Project])
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
483 (setcdr (lookup-key ada-mode-map [menu-bar ada Project])
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
484 submenu))))
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
485 ))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
486
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
487
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
488 ;;-------------------------------------------------------------
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
489 ;;-- Searching a file anywhere on the source path.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
490 ;;--
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
491 ;;-- The following functions provide support for finding a file anywhere
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
492 ;;-- on the source path, without providing an explicit directory.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
493 ;;-- They also provide file name completion in the minibuffer.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
494 ;;--
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
495 ;;-- Public subprograms: ada-find-file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
496 ;;--
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
497 ;;-------------------------------------------------------------
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
498
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
499 (defun ada-do-file-completion (string predicate flag)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
500 "Completion function when reading a file from the minibuffer.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
501 Completion is attempted in all the directories in the source path, as
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
502 defined in the project file."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
503 (let (list
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
504 (dirs (ada-xref-get-src-dir-field)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
505
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
506 (while dirs
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
507 (if (file-directory-p (car dirs))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
508 (set 'list (append list (file-name-all-completions string (car dirs)))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
509 (set 'dirs (cdr dirs)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
510 (cond ((equal flag 'lambda)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
511 (assoc string list))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
512 (flag
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
513 list)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
514 (t
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
515 (try-completion string
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
516 (mapcar (lambda (x) (cons x 1)) list)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
517 predicate)))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
518
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
519 ;;;###autoload
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
520 (defun ada-find-file (filename)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
521 "Open a file anywhere in the source path.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
522 Completion is available."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
523 (interactive
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
524 (list (completing-read "File: " 'ada-do-file-completion)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
525 (let ((file (ada-find-src-file-in-dir filename)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
526 (if file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
527 (find-file file)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
528 (error (concat filename " not found in src_dir")))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
529
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 ;; ----- Keybindings ------------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (defun ada-add-keymap ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
534 "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
535 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (if ada-xemacs
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (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
539 (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
540 (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
541 (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
542
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (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
544 (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
545 (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
546 (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
547 (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
548 (define-key ada-mode-map "\C-cc" 'ada-change-prj)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
549 (define-key ada-mode-map "\C-cd" 'ada-set-default-project-file)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (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
551 (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
552 (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
553 (define-key ada-mode-map "\C-c\C-r" 'ada-find-references)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
554 (define-key ada-mode-map "\C-cl" 'ada-find-local-references)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (define-key ada-mode-map "\C-c\C-v" 'ada-check-current)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
556 (define-key ada-mode-map "\C-cf" 'ada-find-file)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 ;; ----- Menus --------------------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (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
561 "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
562 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
563 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
564 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 (if ada-xemacs
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
566 (let* ((menu-list '("Ada"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
567 (goto-menu '("Ada" "Goto"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
568 (edit-menu '("Ada" "Edit"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
569 (help-menu '("Ada" "Help"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
570 (options-menu (list "Ada" "Options")))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
571 (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
572 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
573 (string= mode-name "Ada")] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
574 (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
575 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
576 (string= mode-name "Ada")] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
577 (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
578 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
579 (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
580 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
581 (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
582 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
583 (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
584 menu-list ["--" nil t] "Goto")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
585 (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
586 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
587 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
588 (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
589 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
590 ada-find-any-references t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
591 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
592 (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
593 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
594 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
595 (funcall (symbol-function 'add-menu-button)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
596 goto-menu ["List Local References" ada-find-local-references t]
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
597 "Next compilation error")
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
598 (funcall (symbol-function 'add-menu-button)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
599 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
600 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
601 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
602 (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
603 goto-menu ["Goto Declaration/Body"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
604 ada-goto-declaration t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
605 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
606 (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
607 goto-menu ["Goto Previous Reference"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
608 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
609 "Next compilation error")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
610 (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
611 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
612 (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
613 edit-menu ["Complete Identifier"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
614 ada-complete-identifier t]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
615 "Indent Line")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
616 (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
617 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
618 (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
619 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
620 (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
621 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
622 (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
623 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
624 (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
625 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
626 (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
627 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
628 (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
629 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
630 ["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
631 (setq ada-xref-other-buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
632 (not ada-xref-other-buffer))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
633 :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
634 (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
635 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
636 ["Automatically Recompile for Cross-References"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
637 (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
638 :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
639 (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
640 options-menu
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
641 ["Confirm Commands"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
642 (setq ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
643 (not ada-xref-confirm-compile))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
644 :style toggle :selected ada-xref-confirm-compile])
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
645 (if (string-match "gvd" ada-prj-default-debugger)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
646 (funcall (symbol-function 'add-menu-button)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
647 options-menu
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
648 ["Tight Integration With Gnu Visual Debugger"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
649 (setq ada-tight-gvd-integration
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
650 (not ada-tight-gvd-integration))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
651 :style toggle :selected ada-tight-gvd-integration]))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
652 )
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
653
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 ;; for Emacs
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
655 (let* ((menu (or (lookup-key ada-mode-map [menu-bar Ada])
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
656 ;; Emacs-21.4's easymenu.el downcases the events.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
657 (lookup-key ada-mode-map [menu-bar ada])))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
658 (edit-menu (or (lookup-key menu [Edit]) (lookup-key menu [edit])))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
659 (help-menu (or (lookup-key menu [Help]) (lookup-key menu [help])))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
660 (goto-menu (or (lookup-key menu [Goto]) (lookup-key menu [goto])))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
661 (options-menu (or (lookup-key menu [Options])
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
662 (lookup-key menu [options]))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
664 (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
665 'Customize)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
666 (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
667 'Check)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
668 (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
669 'Compile)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
670 (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
671 (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
672 (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
673 (define-key-after menu [Project]
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
674 (cons "Project" (make-sparse-keymap)) 'rem)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
676 (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
677 '("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
678 (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
679 '("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
680 (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
681 '("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
682 (define-key help-menu [gdb]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
683 '("Gdb Documentation" . (lambda() (interactive) (info "gdb"))))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
684 (define-key help-menu [arm95]
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
685 '("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
686
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
687 (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
688 (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
689 . ada-goto-parent))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
690 (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
691 '("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
692 (define-key goto-menu [References]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
693 '("List References" . ada-find-references))
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
694 (define-key goto-menu [Local-References]
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
695 '("List Local References" . ada-find-local-references))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
696 (define-key goto-menu [Prev]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
697 '("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
698 (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
699 '("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
700 (define-key goto-menu [Decl]
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
701 '("Goto Declaration/Body" . ada-goto-declaration))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
702
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
703 (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
704 (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
705 . ada-complete-identifier))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
706
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
707 (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
708 '(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
709 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
710 (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
711 :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
712 (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
713 '(menu-item "Confirm Commands"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
714 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
715 (setq ada-xref-confirm-compile
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
716 (not ada-xref-confirm-compile)))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
717 :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
718 (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
719 '(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
720 (lambda()(interactive)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
721 (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
722 :button (:toggle . ada-xref-other-buffer)) t)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
723
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
724 (if (string-match "gvd" ada-prj-default-debugger)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
725 (define-key-after options-menu [tightgvd]
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
726 '(menu-item "Tight Integration With Gnu Visual Debugger"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
727 (lambda()(interactive)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
728 (setq ada-tight-gvd-integration
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
729 (not ada-tight-gvd-integration)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
730 :button (:toggle . ada-tight-gvd-integration)) t))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
731
47745
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
732 (define-key edit-menu [rem3] '("------------" . nil))
36d9421bf776 (ada-xref-update-project-menu,ada-add-ada-menu): Handle the menu
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45930
diff changeset
733 (define-key edit-menu [open-file-from-src-path]
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
734 '("Search File on source path..." . ada-find-file))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 )
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
736 )
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
737 (ada-xref-update-project-menu)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
738 )
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 ;; ----- Utilities -------------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 (defun ada-require-project-file ()
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
743 "If no project file is currently active, load a default one."
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
744 (if (or (not ada-prj-default-project-file)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
745 (not ada-xref-project-files)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
746 (string= ada-prj-default-project-file ""))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
747 (ada-reread-prj-file)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
748
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 (defun ada-xref-push-pos (filename position)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
750 "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
751 (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
752 (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
753 (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
754
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 (defun ada-xref-goto-previous-reference ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
756 "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
757 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 (if ada-xref-pos-ring
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
759 (let ((pos (car ada-xref-pos-ring)))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
760 (setq ada-xref-pos-ring (cdr ada-xref-pos-ring))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
761 (find-file (car (cdr pos)))
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
762 (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
763
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 (defun ada-convert-file-name (name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
765 "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
766 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
767 name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 (defun ada-set-default-project-file (name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
770 "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
771 (interactive "fProject file:")
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
772 (setq 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
773 (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
774 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
776 ;; ------ 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
777
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 (defun ada-prj-find-prj-file (&optional no-user-question)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
779 "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
780 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
781 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
782 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
783 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
784
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
785 (let (selected)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
787 ;; Use the active project file if there is one.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
788 ;; This is also valid if we don't currently have an Ada buffer, or if
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
789 ;; the current buffer is not a real file (for instance an emerge buffer)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
790
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
791 (if (or (not (string= mode-name "Ada"))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
792 (not (buffer-file-name))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
793 (and ada-prj-default-project-file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
794 (not (string= ada-prj-default-project-file ""))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
795 (set 'selected ada-prj-default-project-file)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
796
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
797 ;; other cases: use a more complex algorithm
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
798
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
799 (let* ((current-file (buffer-file-name))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
800 (first-choice (concat
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
801 (file-name-sans-extension current-file)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
802 ada-project-file-extension))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
803 (dir (file-name-directory current-file))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
804
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
805 ;; on Emacs 20.2, directory-files does not work if
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
806 ;; parse-sexp-lookup-properties is set
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
807 (parse-sexp-lookup-properties nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
808 (prj-files (directory-files
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
809 dir t
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
810 (concat ".*" (regexp-quote
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
811 ada-project-file-extension) "$")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
812 (choice nil))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
813
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
814 (cond
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
815
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
816 ;; Else if there is a project file with the same name as the Ada
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
817 ;; file, but not the same extension.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
818 ((file-exists-p first-choice)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
819 (set 'selected first-choice))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
820
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
821 ;; Else if only one project file was found in the current directory
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
822 ((= (length prj-files) 1)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
823 (set 'selected (car prj-files)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
824
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
825 ;; Else if there are multiple files, ask the user
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
826 ((and (> (length prj-files) 1) (not no-user-question))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
827 (save-window-excursion
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
828 (with-output-to-temp-buffer "*choice list*"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
829 (princ "There are more than one possible project file.\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
830 (princ "Which one should we use ?\n\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
831 (princ " no. file name \n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
832 (princ " --- ------------------------\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
833 (let ((counter 1))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
834 (while (<= counter (length prj-files))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
835 (princ (format " %2d) %s\n"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
836 counter
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
837 (nth (1- counter) prj-files)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
838 (setq counter (1+ counter))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
839 ))) ; end of with-output-to ...
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
840 (setq choice nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
841 (while (or
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
842 (not choice)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
843 (not (integerp choice))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
844 (< choice 1)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
845 (> choice (length prj-files)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
846 (setq choice (string-to-int
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
847 (read-from-minibuffer "Enter No. of your choice: "))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
848 (set 'selected (nth (1- choice) prj-files))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
849
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
850 ;; Else if no project file was found in the directory, ask a name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
851 ;; to the user, using as a default value the last one entered by
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
852 ;; the user
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
853 ((= (length prj-files) 0)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
854 (unless (or no-user-question (not ada-always-ask-project))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
855 (setq ada-last-prj-file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
856 (read-file-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
857 (concat "project file [" ada-last-prj-file "]:")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
858 nil ada-last-prj-file))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
859 (unless (string= ada-last-prj-file "")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
860 (set 'selected ada-last-prj-file))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
861 )))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
862 selected
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
863 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 (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
867 "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
868 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
869 (if prj-file
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
870 (let (project src_dir obj_dir make_cmd comp_cmd check_cmd casing
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
871 run_cmd debug_pre_cmd debug_post_cmd
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
872 (ada-buffer (current-buffer)))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
873 (setq 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
874
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
875 ;; 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
876 (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
877
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
878 ;; 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
879 ;; 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
880 ;; 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
881 ;; 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
882
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
883 (let* ((buffer (run-hook-with-args-until-success
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
884 'ada-load-project-hook prj-file)))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
885 (unless buffer
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
886 (setq buffer (find-file-noselect prj-file nil)))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
887 (set-buffer buffer))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
888
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
889 (widen)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
890 (goto-char (point-min))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
891
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
892 ;; 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
893 (while (not (eobp))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
894 (if (looking-at "^\\([^=]+\\)=\\(.*\\)")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
895 (cond
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
896 ((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
897 (add-to-list 'src_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
898 (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
899 ((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
900 (add-to-list 'obj_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
901 (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
902 ((string= (match-string 1) "casing")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
903 (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
904 ((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
905 (set 'project
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
906 (plist-put project 'build_dir
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
907 (file-name-as-directory (match-string 2)))))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
908 ((string= (match-string 1) "make_cmd")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
909 (add-to-list 'make_cmd (match-string 2)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
910 ((string= (match-string 1) "comp_cmd")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
911 (add-to-list 'comp_cmd (match-string 2)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
912 ((string= (match-string 1) "check_cmd")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
913 (add-to-list 'check_cmd (match-string 2)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
914 ((string= (match-string 1) "run_cmd")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
915 (add-to-list 'run_cmd (match-string 2)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
916 ((string= (match-string 1) "debug_pre_cmd")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
917 (add-to-list 'debug_pre_cmd (match-string 2)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
918 ((string= (match-string 1) "debug_post_cmd")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
919 (add-to-list 'debug_post_cmd (match-string 2)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
920 (t
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
921 (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
922 (match-string 2))))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
923 (forward-line 1))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
924
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
925 (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
926 (reverse src_dir))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
927 (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
928 (reverse obj_dir))))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
929 (if casing (set 'project (plist-put project 'casing
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
930 (reverse casing))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
931 (if make_cmd (set 'project (plist-put project 'make_cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
932 (reverse make_cmd))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
933 (if comp_cmd (set 'project (plist-put project 'comp_cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
934 (reverse comp_cmd))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
935 (if check_cmd (set 'project (plist-put project 'check_cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
936 (reverse check_cmd))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
937 (if run_cmd (set 'project (plist-put project 'run_cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
938 (reverse run_cmd))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
939 (set 'project (plist-put project 'debug_post_cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
940 (reverse debug_post_cmd)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
941 (set 'project (plist-put project 'debug_pre_cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
942 (reverse debug_pre_cmd)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
943
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
944 ;; Delete the default project file from the list, if it is there.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
945 ;; Note that in that case, this default project is the only one in
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
946 ;; the list
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
947 (if (assoc nil ada-xref-project-files)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
948 (setq ada-xref-project-files nil))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
949
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
950 ;; 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
951 (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
952 (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
953 (add-to-list 'ada-xref-project-files (cons prj-file project)))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
954
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
955 ;; Set the project file as the active one.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
956 (setq ada-prj-default-project-file prj-file)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
957
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
958 ;; 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
959 ;; go to the source of the errors in a compilation buffer
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
960 (setq compilation-search-path (ada-xref-get-src-dir-field))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
961
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
962 ;; Set the casing exceptions file list
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
963 (if casing
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
964 (progn
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
965 (setq ada-case-exception-file (reverse casing))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
966 (ada-case-read-exceptions)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
967
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
968 ;; 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
969 ;; Do not add the '/' or '\' at the end
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
970 (setq ada-search-directories
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
971 (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
972 ada-search-directories))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
973
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
974 ;; Kill the project buffer
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
975 (kill-buffer nil)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
976 (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
977
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
978 (ada-xref-update-project-menu)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
979 )
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
980
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
981 ;; No prj file ? => Setup default values
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
982 ;; Note that nil means that all compilation modes will first look in the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
983 ;; current directory, and only then in the current file's directory. This
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
984 ;; current file is assumed at this point to be in the common source
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
985 ;; directory.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
986 (setq compilation-search-path (list nil default-directory))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
987 ))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
988
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
989
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
990 (defun ada-find-references (&optional pos arg local-only)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
991 "Find all references to the entity under POS.
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
992 Calls gnatfind to find the references.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
993 if ARG is t, the contents of the old *gnatfind* buffer is preserved.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
994 if LOCAL-ONLY is t, only the declarations in the current file are returned."
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
995 (interactive "d
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
996 P")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
997 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
998
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
999 (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
1000 (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
1001 (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
1002
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1003 (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
1004
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1005 ;; 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
1006 (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
1007 (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
1008 (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
1009 (ada-file-of identlist)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1010 nil nil local-only arg)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1011 (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
1012 (ada-file-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1013 (ada-line-of identlist)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1014 (ada-column-of identlist) local-only arg)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1015 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1016
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1017 (defun ada-find-local-references (&optional pos arg)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1018 "Find all references to the entity under POS.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1019 Calls gnatfind to find the references.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1020 if ARG is t, the contents of the old *gnatfind* buffer is preserved."
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1021 (interactive "d
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1022 P")
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1023 (ada-find-references pos arg t))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1024
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1025 (defun ada-find-any-references
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1026 (entity &optional file line column local-only append)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1027 "Search for references to any entity whose name is ENTITY.
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1028 ENTITY was first found the location given by FILE, LINE and COLUMN.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1029 If LOCAL-ONLY is t, then only the references in file will be listed, which
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1030 is much faster.
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1031 If APPEND is t, then the output of the command will be append to the existing
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1032 buffer *gnatfind* if it exists."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1033 (interactive "sEntity name: ")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1034 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1035
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1036 ;; Prepare the gnatfind command. Note that we must protect the quotes
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1037 ;; around operators, so that they are correctly handled and can be
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1038 ;; processed (gnatfind \"+\":...).
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1039 (let* ((quote-entity
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1040 (if (= (aref entity 0) ?\")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1041 (if is-windows
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1042 (concat "\\\"" (substring entity 1 -1) "\\\"")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1043 (concat "'\"" (substring entity 1 -1) "\"'"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1044 entity))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1045 (switches (ada-xref-get-project-field 'gnatfind_opt))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1046 (command (concat "gnatfind " switches " "
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1047 quote-entity
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1048 (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
1049 (if line (concat ":" line))
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1050 (if column (concat ":" column))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1051 (if local-only (concat " " (file-name-nondirectory file)))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1052 ))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1053 old-contents)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1054
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1055 ;; If a project file is defined, use it
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1056 (if (and ada-prj-default-project-file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1057 (not (string= ada-prj-default-project-file "")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1058 (setq command (concat command " -p" ada-prj-default-project-file)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1059
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1060 (if (and append (get-buffer "*gnatfind*"))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1061 (save-excursion
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1062 (set-buffer "*gnatfind*")
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1063 (setq old-contents (buffer-string))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1064
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1065 (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
1066
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1067 ;; Hide the "Compilation" menu
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1068 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1069 (set-buffer "*gnatfind*")
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1070 (local-unset-key [menu-bar compilation-menu])
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1071
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1072 (if old-contents
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1073 (progn
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1074 (goto-char 1)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1075 (insert old-contents)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1076 (goto-char (point-max)))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1077 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1078 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1079
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1080 (defalias 'ada-change-prj (symbol-function 'ada-set-default-project-file))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1081
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1082 ;; ----- Identlist manipulation -------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1083 ;; 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
1084 ;; 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
1085
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1086 (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
1087 (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
1088 (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
1089 (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
1090 (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
1091 (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
1092 (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
1093 (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
1094 (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
1095
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1096 (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
1097 (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
1098 (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
1099 (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
1100 (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
1101 (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
1102 (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
1103 (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
1104
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1105 (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
1106 "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
1107 (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
1108
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1109
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1110
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1111 ;; ----- Identifier Completion --------------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1112 (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
1113 "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
1114 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
1115 option."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1116 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1117 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1118
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1119 ;; 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
1120 ;; 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
1121 (let* ((curbuf (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1122 (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
1123 (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
1124 (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
1125 "[a-zA-Z0-9_]*\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1126 (completed nil)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1127 (symalist nil))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1128
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1129 ;; Open the .ali file
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1130 (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
1131 (goto-char (point-max))
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 ;; 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
1134 (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
1135 (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
1136
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1137 (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
1138
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1139 ;; kills .ali buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1140 (kill-buffer nil)
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 ;; 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
1143 (set-buffer curbuf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1144 (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
1145 (replace-match "")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1146 ;; inserts the completed symbol
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1147 (insert completed)
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
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1150 ;; ----- Cross-referencing ----------------------------------------
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1151
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1152 (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
1153 "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
1154 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1155 (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
1156 (ada-goto-declaration (point)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1157
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1158 (defun ada-goto-declaration (pos &optional other-frame)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1159 "Display the declaration of the identifier around POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1160 The declaration is shown in another buffer if `ada-xref-other-buffer' is
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1161 non-nil.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1162 If OTHER-FRAME is non-nil, display the cross-reference in another frame."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1163 (interactive "d")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1164 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1165 (push-mark pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1166 (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
1167
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1168 ;; First try the standard algorithm by looking into the .ali file, but if
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1169 ;; that file was too old or even did not exist, try to look in the whole
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1170 ;; object path for a possible location.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1171 (let ((identlist (ada-read-identifier pos)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1172 (condition-case nil
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1173 (ada-find-in-ali identlist other-frame)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1174 (error
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1175 (let ((ali-file (ada-get-ali-file-name (ada-file-of identlist))))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1176
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1177 ;; If the ALI file was up-to-date, then we probably have a predefined
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1178 ;; entity, whose references are not given by GNAT
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1179 (if (and (file-exists-p ali-file)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1180 (file-newer-than-file-p ali-file (ada-file-of identlist)))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1181 (message "No cross-reference found. It might be a predefined entity.")
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1182
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1183 ;; Else, look in every ALI file, except if the user doesn't want that
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1184 (if ada-xref-search-with-egrep
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1185 (ada-find-in-src-path identlist other-frame)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1186 (message "Cross-referencing information is not up-to-date. Please recompile.")
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1187 )))))))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1188
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1189 (defun ada-goto-declaration-other-frame (pos &optional other-frame)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1190 "Display the declaration of the identifier around POS.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1191 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
1192 (interactive "d")
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1193 (ada-goto-declaration pos t))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1194
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1195 (defun ada-remote (command)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1196 "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
1197 (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
1198 (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
1199 command
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1200 (format "%s %s '(%s)'"
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1201 remote-shell-program
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1202 machine
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1203 command))))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1204
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1205 (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
1206 "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
1207 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
1208 front."
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1209 (mapcar (lambda (x) (expand-file-name x root-dir)) dir-list))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1210
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1211 (defun ada-set-environment ()
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1212 "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
1213 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
1214 project file."
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1215 (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
1216 (objects (getenv "ADA_OBJECTS_PATH"))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1217 (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
1218 (if include
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1219 (set 'include (concat path-separator include)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1220 (if objects
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1221 (set 'objects (concat path-separator objects)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1222 (cons
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1223 (concat "ADA_INCLUDE_PATH="
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1224 (mapconcat (lambda(x) (expand-file-name x build-dir))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1225 (ada-xref-get-project-field 'src_dir)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1226 path-separator)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1227 include)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1228 (cons
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1229 (concat "ADA_OBJECTS_PATH="
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1230 (mapconcat (lambda(x) (expand-file-name x build-dir))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1231 (ada-xref-get-project-field 'obj_dir)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1232 path-separator)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1233 objects)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1234 process-environment))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1235
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1236 (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
1237 "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
1238 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
1239 (interactive "P")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1240 (ada-require-project-file)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1241 (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
1242 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1243 (compilation-scroll-output t))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1244
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1245 (setq compilation-search-path (ada-xref-get-src-dir-field))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1246
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1247 ;; 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
1248 (unless cmd
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1249 (setq cmd '("") arg t))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1250
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1251 ;; Make a single command from the list of commands, including the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1252 ;; commands to run it on a remote machine.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1253 (setq cmd (ada-remote (mapconcat 'identity cmd ada-command-separator)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1254
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1255 (if (or ada-xref-confirm-compile arg)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1256 (setq cmd (read-from-minibuffer "enter command to compile: " cmd)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1257
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1258 ;; Insert newlines so as to separate the name of the commands to run
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1259 ;; and the output of the commands. this doesn't work with cmdproxy.exe,
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1260 ;; which gets confused by newline characters.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1261 (if (not (string-match "cmdproxy.exe" shell-file-name))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1262 (setq cmd (concat cmd "\n\n")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1263
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1264 (compile (ada-quote-cmd cmd))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1265
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1266 (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
1267 "Recompile the current file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1268 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
1269 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
1270 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
1271 (interactive "P")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1272 (ada-require-project-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1273 (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
1274 (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
1275 (process-environment (ada-set-environment))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1276 (compilation-scroll-output t))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1277
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1278 (setq compilation-search-path (ada-xref-get-src-dir-field))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1279
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1280 (unless cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1281 (setq cmd '("") arg t))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1282
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1283 ;; Make a single command from the list of commands, including the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1284 ;; commands to run it on a remote machine.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1285 (setq cmd (ada-remote (mapconcat 'identity cmd ada-command-separator)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1286
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1287 ;; If no project file was found, ask the user
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1288 (if (or ada-xref-confirm-compile arg)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1289 (setq cmd (read-from-minibuffer "enter command to compile: " cmd)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1290
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1291 ;; Insert newlines so as to separate the name of the commands to run
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1292 ;; and the output of the commands. this doesn't work with cmdproxy.exe,
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1293 ;; which gets confused by newline characters.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1294 (if (not (string-match "cmdproxy.exe" shell-file-name))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1295 (setq cmd (concat cmd "\n\n")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1296
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1297 (compile (ada-quote-cmd cmd))))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1298
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1299 (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
1300 "Recompile the current file.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1301 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
1302 (interactive "P")
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1303 (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
1304
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1305 (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
1306 "Run the application.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1307 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
1308 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1309 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1310
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1311 (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
1312 (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
1313 (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
1314
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1315 (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
1316
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1317 ;; Guess the command if it wasn't specified
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1318 (if (not command)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1319 (set 'command (list (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
1320
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1321 ;; Modify the command to run remotely
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1322 (setq command (ada-remote (mapconcat 'identity command
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1323 ada-command-separator)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1324
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1325 ;; 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
1326 (if (or ada-xref-confirm-compile arg)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1327 (setq command (read-from-minibuffer "Enter command to execute: "
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1328 command)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1329
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1330 ;; Run the command
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1331 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1332 (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
1333 (set 'buffer-read-only nil)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1334
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1335 (erase-buffer)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1336 (start-process "run" (current-buffer) shell-file-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1337 "-c" command)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1338 (comint-mode)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1339 ;; Set these two variables to their default values, since otherwise
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1340 ;; the output buffer is scrolled so that only the last output line
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1341 ;; is visible at the top of the buffer.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1342 (set (make-local-variable 'scroll-step) 0)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1343 (set (make-local-variable 'scroll-conservatively) 0)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1344 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1345 (display-buffer "*run*")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1346
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1347 ;; 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
1348 (other-window 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1349 (switch-to-buffer "*run*")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1350 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1351
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1352 (defun ada-gdb-application (&optional arg executable-name)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1353 "Start the debugger on the application.
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1354 EXECUTABLE-NAME, if non-nil, is debugged instead of the file specified in the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1355 project file.
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1356 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
1357 (interactive "P")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1358 (let ((buffer (current-buffer))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1359 cmd pre-cmd post-cmd)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1360 (ada-require-project-file)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1361 (setq cmd (if executable-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1362 (concat ada-prj-default-debugger " " executable-name)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1363 (ada-xref-get-project-field 'debug_cmd))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1364 pre-cmd (ada-xref-get-project-field 'debug_pre_cmd)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1365 post-cmd (ada-xref-get-project-field 'debug_post_cmd))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1366
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1367 ;; 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
1368 (if (not cmd)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1369 (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
1370 " "
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1371 (or executable-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1372 (file-name-sans-extension (buffer-file-name))))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1373
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1374 ;; For gvd, add an extra switch so that the Emacs window is completly
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1375 ;; swallowed inside the Gvd one
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1376 (if (and ada-tight-gvd-integration
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1377 (string-match "^[^ \t]*gvd" cmd))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1378 ;; Start a new frame, so that when gvd exists we do not kill Emacs
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1379 ;; We make sure that gvd swallows the new frame, not the one the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1380 ;; user has been using until now
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1381 ;; The frame is made invisible initially, so that GtkPlug gets a
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1382 ;; chance to fully manage it. Then it works fine with Enlightenment
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1383 ;; as well
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1384 (let ((frame (make-frame '((visibility . nil)))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1385 (set 'cmd (concat
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1386 cmd " --editor-window="
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1387 (cdr (assoc 'outer-window-id (frame-parameters frame)))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1388 (select-frame frame)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1389
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1390 ;; Add a -fullname switch
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1391 ;; Use the remote machine
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1392 (set 'cmd (ada-remote (concat cmd " -fullname ")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1393
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1394 ;; Ask for confirmation if required
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1395 (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
1396 (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
1397
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1398 (let (comint-exec
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1399 in-post-mode
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1400 gud-gdb-massage-args)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1401
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1402 ;; Do not add -fullname, since we can have a 'rsh' command in front.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1403 (fset 'gud-gdb-massage-args (lambda (file args) args))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1404
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1405 (set 'pre-cmd (mapconcat 'identity pre-cmd ada-command-separator))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1406 (if (not (equal pre-cmd ""))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1407 (setq pre-cmd (concat pre-cmd ada-command-separator)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1408
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1409 (set 'post-cmd (mapconcat 'identity post-cmd "\n"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1410 (if post-cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1411 (set 'post-cmd (concat post-cmd "\n")))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1412
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1413 ;; Temporarily replaces the definition of `comint-exec' so that we
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1414 ;; can execute commands before running gdb.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1415 (fset 'comint-exec
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1416 `(lambda (buffer name command startfile switches)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1417 (let (compilation-buffer-name-function)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1418 (save-excursion
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1419 (set 'compilation-buffer-name-function
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1420 (lambda(x) (buffer-name buffer)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1421 (compile (ada-quote-cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1422 (concat ,pre-cmd
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1423 command " "
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1424 (mapconcat 'identity switches " "))))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1425 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1426
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1427 ;; Tight integration should force the tty mode
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1428 (if (and (string-match "gvd" (comint-arguments cmd 0 0))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1429 ada-tight-gvd-integration
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1430 (not (string-match "--tty" cmd)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1431 (setq cmd (concat cmd "--tty")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1432
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1433 (if (and (string-match "jdb" (comint-arguments cmd 0 0))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1434 (boundp 'jdb))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1435 (funcall (symbol-function 'jdb) cmd)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1436 (gdb cmd))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1437
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1438 ;; Send post-commands to the debugger
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1439 (process-send-string (get-buffer-process (current-buffer)) post-cmd)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1440
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1441 ;; Move to the end of the debugger buffer, so that it is automatically
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1442 ;; scrolled from then on.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1443 (end-of-buffer)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1444
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1445 ;; Display both the source window and the debugger window (the former
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1446 ;; above the latter). No need to show the debugger window unless it
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1447 ;; is going to have some relevant information.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1448 (if (or (not (string-match "gvd" (comint-arguments cmd 0 0)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1449 (string-match "--tty" cmd))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1450 (split-window-vertically))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1451 (switch-to-buffer buffer)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1452 )))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1453
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1454
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1455 (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
1456 "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
1457 with the current buffer.
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1458 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
1459 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
1460 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
1461 (interactive "P")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1462 (if filename
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1463 (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
1464 (ada-parse-prj-file (ada-prj-find-prj-file)))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1465
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1466 ;; Reread the location of the standard runtime library
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1467 (ada-initialize-runtime-library
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1468 (or (ada-xref-get-project-field 'cross-prefix) ""))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1469 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1470
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1471 ;; ------ Private routines
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1472
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1473 (defun ada-xref-current (file &optional ali-file-name)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1474 "Update the cross-references for FILE.
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1475 This in fact recompiles FILE to create ALI-FILE-NAME.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1476 This function returns the name of the file that was recompiled to generate
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1477 the cross-reference information. Note that the ali file can then be deduced by
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1478 replacing the file extension with .ali"
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1479 ;; kill old buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1480 (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
1481 (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
1482 (kill-buffer (get-file-buffer ali-file-name)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1483
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1484 (let* ((name (ada-convert-file-name file))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1485 (body-name (or (ada-get-body-name name) name)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1486
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1487 ;; Always recompile the body when we can. We thus temporarily switch to a
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1488 ;; buffer than contains the body of the unit
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1489 (save-excursion
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1490 (let ((body-visible (find-buffer-visiting body-name))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1491 process)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1492 (if body-visible
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1493 (set-buffer body-visible)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1494 (find-file body-name))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1495
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1496 ;; Execute the compilation. Note that we must wait for the end of the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1497 ;; process, or the ALI file would still not be available.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1498 ;; Unfortunately, the underlying `compile' command that we use is
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1499 ;; asynchronous.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1500 (ada-compile-current)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1501 (setq process (get-buffer-process "*compilation*"))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1502
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1503 (while (and process
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1504 (not (equal (process-status process) 'exit)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1505 (sit-for 1))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1506
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1507 ;; remove the buffer for the body if it wasn't there before
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1508 (unless body-visible
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1509 (kill-buffer (find-buffer-visiting body-name)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1510 ))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1511 body-name))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1512
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1513 (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
1514 "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
1515 (let (found)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1516 (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
1517 (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
1518 (file-name-nondirectory file)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1519
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1520 (unless (file-exists-p found)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1521 (set 'found nil))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1522 (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
1523 found))
25899
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 (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
1526 "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
1527 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
1528 and the standard runtime location at the end."
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1529 (ada-find-file-in-dir file (ada-xref-get-obj-dir-field)))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1530
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1531 (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
1532 "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
1533 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
1534 and the standard runtime location at the end."
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1535 (ada-find-file-in-dir file (ada-xref-get-src-dir-field)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1536
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1537 (defun ada-get-ali-file-name (file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1538 "Create the ali file name for the ada-file FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1539 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
1540 the project file."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1541
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1542 ;; 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
1543 ;; 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
1544 ;; 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
1545 ;; 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
1546 ;; 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
1547 ;; 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
1548 ;; 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
1549 ;; .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
1550 ;; 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
1551 ;; 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
1552 ;; for its associated .ali file by subtituing the extension
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1553 ;;
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1554 ;; We must also handle the case of separate packages and subprograms:
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1555 ;; 4- If no ali file was found, we try to modify the file name by removing
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1556 ;; everything after the last '-' or '.' character, so as to get the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1557 ;; ali file for the parent unit. If we found an ali file, we check that
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1558 ;; it indeed contains the definition for the separate entity by checking
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1559 ;; the 'D' lines. This is done repeatedly, in case the direct parent is
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1560 ;; also a separate.
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1561
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1562 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1563 (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
1564 (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
1565 (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
1566 ".ali"))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1567 ali-file-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1568 is-spec)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1569
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1570 ;; If we have a non-standard file name, and this is a spec, we first
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1571 ;; look for the .ali file of the body, since this is the one that
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1572 ;; contains the most complete information. If not found, we will do what
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1573 ;; we can with the .ali file for the spec...
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1574
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1575 (if (not (string= (file-name-extension file) "ads"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1576 (let ((specs ada-spec-suffixes))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1577 (while specs
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1578 (if (string-match (concat (regexp-quote (car specs)) "$")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1579 file)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1580 (set 'is-spec t))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1581 (set 'specs (cdr specs)))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1582
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1583 (if is-spec
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1584 (set 'ali-file-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1585 (ada-find-ali-file-in-dir
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1586 (concat (file-name-sans-extension
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1587 (file-name-nondirectory
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1588 (ada-other-file-name)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1589 ".ali"))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1590
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1591
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1592 (setq ali-file-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1593 (or ali-file-name
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1594
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1595 ;; Else we take the .ali file associated with the unit
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1596 (ada-find-ali-file-in-dir short-ali-file-name)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1597
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1598
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1599 ;; else we did not find the .ali file Second chance: in case
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1600 ;; the files do not have standard names (such as for instance
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1601 ;; file_s.ada and file_b.ada), try to go to the other file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1602 ;; and look for its ali file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1603 (ada-find-ali-file-in-dir
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1604 (concat (file-name-sans-extension
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1605 (file-name-nondirectory (ada-other-file-name)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1606 ".ali"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1607
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1608
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1609 ;; If we still don't have an ali file, try to get the one
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1610 ;; from the parent unit, in case we have a separate entity.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1611 (let ((parent-name (file-name-sans-extension
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1612 (file-name-nondirectory file))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1613
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1614 (while (and (not ali-file-name)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1615 (string-match "^\\(.*\\)[.-][^.-]*" parent-name))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1616
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1617 (set 'parent-name (match-string 1 parent-name))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1618 (set 'ali-file-name (ada-find-ali-file-in-dir
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1619 (concat parent-name ".ali")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1620 )
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1621 ali-file-name)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1622
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1623 ;; If still not found, try to recompile the file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1624 (if (not ali-file-name)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1625 ;; recompile only if the user asked for this. and search the ali
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1626 ;; filename again. We avoid a possible infinite recursion by
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1627 ;; temporarily disabling the automatic compilation.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1628
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1629 (if ada-xref-create-ali
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1630 (setq ali-file-name
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1631 (concat (file-name-sans-extension (ada-xref-current file))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1632 ".ali"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1633
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1634 (error "Ali file not found. Recompile your file"))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1635
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1636
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1637 ;; same if the .ali file is too old and we must recompile it
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1638 (if (and (file-newer-than-file-p file ali-file-name)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1639 ada-xref-create-ali)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1640 (ada-xref-current file ali-file-name)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1641
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1642 ;; Always return the correct absolute file name
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1643 (expand-file-name ali-file-name))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1644 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1645
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1646 (defun ada-get-ada-file-name (file original-file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1647 "Create the complete file name (+directory) for FILE.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1648 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
1649 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
1650
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1651 (save-excursion
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1652
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1653 ;; 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
1654 ;; 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
1655 (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
1656 (if buffer
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1657 (set-buffer buffer)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1658 (find-file original-file)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1659 (ada-require-project-file)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1660
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1661 ;; 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
1662 ;; 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
1663 (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
1664 (if filename
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1665 (expand-file-name filename)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1666 (error (concat
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1667 (file-name-nondirectory file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1668 " 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
1669
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
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1672 (defun ada-find-file-number-in-ali (file)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1673 "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
1674 (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
1675 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1676
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1677 (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
1678 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1679 (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
1680 (count-lines begin (point))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1681
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1682 (defun ada-read-identifier (pos)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1683 "Returns the identlist around POS and switch to the .ali buffer.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1684 The returned list represents the entity, and can be manipulated through the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1685 macros `ada-name-of', `ada-line-of', `ada-column-of', `ada-file-of',..."
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1686
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1687 ;; 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
1688 (if (>= (point) (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1689 (error "No identifier on point"))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1690
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1691 ;; 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
1692 ;; 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
1693 (goto-char pos)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1694 (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
1695
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1696 ;; 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
1697 (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
1698 (error "Inside comment"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1699
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1700 (let (identifier identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1701 ;; 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
1702 ;; as in "+", "-", ..
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1703 (if (= (char-after) ?\")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1704 (forward-char 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1705
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1706 ;; 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
1707 ;; This is only true if:
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1708 ;; - the symbol is +, -, ...
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1709 ;; - 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
1710 (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
1711 (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
1712 (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
1713 (= (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
1714 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1715 (if (and (= (char-before) ?\")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1716 (= (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
1717 (forward-char -1))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1718 (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
1719
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1720 (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
1721 (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
1722 (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
1723 (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
1724 (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
1725 (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
1726 (error "No identifier around")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1727
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1728 ;; Build the identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1729 (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
1730 (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
1731 (ada-set-line identlist
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1732 (number-to-string (count-lines 1 (point))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1733 (ada-set-column identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1734 (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
1735 (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
1736 identlist
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 (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
1740 "Completes and returns IDENTLIST with the information extracted
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1741 from the ali file (definition file and places where it is referenced)."
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1742
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1743 (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
1744 declaration-found)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1745 (set-buffer ali-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1746 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1747 (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
1748
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1749 ;; 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
1750 ;; 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
1751 ;; the "^X ..." line for the current file, and before the next "^X" line
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1752
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1753 (if (re-search-forward
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1754 (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
1755 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1756 (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
1757 (set 'declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1758 (re-search-forward
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1759 (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
1760 "." (ada-column-of identlist)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1761 "[ *]" (ada-name-of identlist)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1762 "[{\(<= ]?\\(.*\\)$") bound t))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1763 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1764 (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
1765 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1766
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1767 ;; 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
1768 ;; 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
1769
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1770 (unless declaration-found
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1771
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1772 ;; 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
1773 ;; reference to it
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1774 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1775 (set 'declaration-found t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1776 (ada-set-ali-index
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1777 identlist
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1778 (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
1779 (ada-file-of identlist))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1780 (unless (re-search-forward (concat (ada-ali-index-of identlist)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1781 "|\\([0-9]+[^0-9][0-9]+\\(\n\\.\\)? \\)*"
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1782 (ada-line-of identlist)
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1783 "[^etp]"
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1784 (ada-column-of identlist) "\\>")
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1785 nil t)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1786
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1787 ;; 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
1788 ;; 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
1789 ;; Or maybe we are already on the declaration...
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1790 (unless (re-search-forward
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1791 (concat
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1792 "^[0-9]+.[0-9]+[ *]"
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1793 (ada-name-of identlist)
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1794 "[ <{=\(]\\(.\\|\n\\.\\)*\\<"
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1795 (ada-line-of identlist)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1796 "[^0-9]"
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1797 (ada-column-of identlist) "\\>")
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1798 nil t)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1799
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1800 ;; 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
1801 ;; 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
1802 ;; created
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1803 (set 'declaration-found nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1804 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1805 )
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 ;; 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
1808 ;; 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
1809 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1810 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1811 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1812 ;; 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
1813 (while (looking-at "^\\.")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1814 (previous-line 1))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1815 (unless (looking-at (concat "[0-9]+.[0-9]+[ *]"
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1816 (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
1817 (set 'declaration-found nil))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1818
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1819 ;; 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
1820 ;; 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
1821 ;; 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
1822 ;; automatically
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1823 (unless declaration-found
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1824 (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
1825 (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
1826 ;; 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
1827 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1828 (kill-buffer ali-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1829 (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
1830 " found."))
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
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1834
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1835 ;; 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
1836 ;; information available
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1837 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1838 (if declaration-found
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1839 (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
1840 (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
1841 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1842 (next-line 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1843 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1844 (while (looking-at "^\\.\\(.*\\)")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1845 (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
1846 (next-line 1))
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 (if (re-search-backward "^X [0-9]+ \\([a-zA-Z0-9_.-]+\\)" nil t)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1850
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1851 ;; If we can find the file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1852 (condition-case err
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1853 (ada-set-declare-file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1854 identlist
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1855 (ada-get-ada-file-name (match-string 1)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1856 (ada-file-of identlist)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1857
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1858 ;; Else clean up the ali file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1859 (error
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1860 (kill-buffer ali-buffer)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1861 (error (error-message-string err)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1862 ))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1863
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1864 (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
1865 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1866 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1867
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1868 (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
1869 "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
1870 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
1871 to make some guesses.
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1872 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
1873
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1874 (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
1875 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1876 (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
1877 (my-regexp (concat "[ *]"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1878 (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
1879 (line-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1880 (col-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1881 (line-ali 0)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1882 (len 0)
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1883 (choice 0)
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1884 (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
1885
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1886 (goto-char (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1887 (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
1888 (save-excursion
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
1889 (setq line-ali (count-lines 1 (point)))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1890 (beginning-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1891 ;; 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
1892 (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
1893 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1894 (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
1895 (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
1896 (setq line-ada "--")
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1897 (setq col-ada "--")
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 ;; 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
1900 (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
1901 (add-to-list
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1902 '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
1903 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1904 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1905 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1906
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1907 ;; 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
1908 (setq len (length declist))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1909 (cond
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1910 ;; none => error
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1911 ((= len 0)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1912 (kill-buffer (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1913 (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
1914 (ada-name-of identlist)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1915 " recorded in .ali file")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1916
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1917 ;; 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
1918 ((= len 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1919 (goto-line (caar declist)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1920
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1921 ;; 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
1922 (t
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1923 (save-window-excursion
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1924 (with-output-to-temp-buffer "*choice list*"
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1925
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1926 (princ "Identifier is overloaded and Xref information is not up to date.\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1927 (princ "Possible declarations are:\n\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1928 (princ " no. in file at line col\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1929 (princ " --- --------------------- ---- ----\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1930 (let ((counter 0))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1931 (while (< counter len)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1932 (princ (format " %2d) %-21s %4s %4s\n"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1933 (1+ counter)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1934 (ada-get-ada-file-name
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1935 (nth 1 (nth counter declist))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1936 (ada-file-of identlist))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1937 (nth 2 (nth counter declist))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1938 (nth 3 (nth counter declist))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1939 ))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1940 (setq counter (1+ counter))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1941 ) ; end of while
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1942 ) ; end of let
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1943 ) ; end of with-output-to ...
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1944 (setq choice nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1945 (while (or
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1946 (not choice)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1947 (not (integerp choice))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1948 (< choice 1)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1949 (> choice len))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1950 (setq choice
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1951 (string-to-int
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1952 (read-from-minibuffer "Enter No. of your choice: "))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1953 )
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
1954 (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
1955 (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
1956 ))))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1957
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1958
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1959 (defun ada-find-in-ali (identlist &optional other-frame)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
1960 "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
1961 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
1962 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
1963
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1964 (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
1965 (let ((ali-line (ada-references-of identlist))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1966 (locations nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1967 (start 0)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1968 file line col)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1969
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1970 ;; Note: in some cases, an entity can have multiple references to the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1971 ;; bodies (this is for instance the case for a separate subprogram, that
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1972 ;; has a reference both to the stub and to the real body).
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1973 ;; In that case, we simply go to each one in turn.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1974
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1975 ;; Get all the possible locations
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1976 (string-match "^\\([0-9]+\\)[a-zA-Z+]\\([0-9]+\\)[ *]" ali-line)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1977 (set 'locations (list (list (match-string 1 ali-line) ;; line
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1978 (match-string 2 ali-line) ;; column
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1979 (ada-declare-file-of identlist))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1980 (while (string-match "\\([0-9]+\\)[bc]\\([0-9]+\\)" ali-line start)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1981 (setq line (match-string 1 ali-line)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1982 col (match-string 2 ali-line)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1983 start (match-end 2))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1984
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1985 ;; it there was a file number in the same line
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1986 (if (string-match (concat "\\([0-9]+\\)|\\([^|bc]+\\)?"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1987 (match-string 0 ali-line))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1988 ali-line)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1989 (let ((file-number (match-string 1 ali-line)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1990 (goto-char (point-min))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1991 (re-search-forward "^D \\([a-zA-Z0-9_.-]+\\)" nil t
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1992 (string-to-number file-number))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1993 (set 'file (match-string 1))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1994 )
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1995 ;; Else get the nearest file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1996 (set 'file (ada-declare-file-of identlist)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
1997
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1998 (set 'locations (append locations (list (list line col file)))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
1999
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2000 ;; Add the specs at the end again, so that from the last body we go to
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2001 ;; the specs
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2002 (set 'locations (append locations (list (car locations))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2003
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2004 ;; Find the new location we want to go to.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2005 ;; If we are on none of the locations listed, we simply go to the specs.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2006
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2007 (setq line (caar locations)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2008 col (nth 1 (car locations))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2009 file (nth 2 (car locations)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2010
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2011 (while locations
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2012 (if (and (string= (caar locations) (ada-line-of identlist))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2013 (string= (nth 1 (car locations)) (ada-column-of identlist))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2014 (string= (file-name-nondirectory (nth 2 (car locations)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2015 (file-name-nondirectory (ada-file-of identlist))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2016 (setq locations (cadr locations)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2017 line (car locations)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2018 col (nth 1 locations)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2019 file (nth 2 locations)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2020 locations nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2021 (set 'locations (cdr locations))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2022
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2023 ;; Find the file in the source path
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2024 (set 'file (ada-get-ada-file-name file (ada-file-of identlist)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2025
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2026 ;; Kill the .ali buffer
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2027 (kill-buffer (current-buffer))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2028
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2029 ;; Now go to the buffer
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2030 (ada-xref-change-buffer file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2031 (string-to-number line)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2032 (1- (string-to-number col))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2033 identlist
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2034 other-frame)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2035 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2036
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2037 (defun ada-find-in-src-path (identlist &optional other-frame)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2038 "More general function for cross-references.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2039 This function should be used when the standard algorithm that parses the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2040 .ali file has failed, either because that file was too old or even did not
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2041 exist.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2042 This function attempts to find the possible declarations for the identifier
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2043 anywhere in the object path.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2044 This command requires the external `egrep' program to be available.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2045
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2046 This works well when one is using an external librarie and wants
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2047 to find the declaration and documentation of the subprograms one is
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2048 is using."
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2049
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2050 (let (list
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2051 (dirs (ada-xref-get-obj-dir-field))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2052 (regexp (concat "[ *]" (ada-name-of identlist)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2053 line column
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2054 choice
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2055 file)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2056
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2057 (save-excursion
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2058
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2059 ;; Do the grep in all the directories. We do multiple shell
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2060 ;; commands instead of one in case there is no .ali file in one
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2061 ;; of the directory and the shell stops because of that.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2062
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2063 (set-buffer (get-buffer-create "*grep*"))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2064 (while dirs
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2065 (insert (shell-command-to-string
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2066 (concat "egrep -i -h '^X|" regexp "( |$)' "
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2067 (file-name-as-directory (car dirs)) "*.ali")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2068 (set 'dirs (cdr dirs)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2069
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2070 ;; Now parse the output
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2071 (set 'case-fold-search t)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2072 (goto-char (point-min))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2073 (while (re-search-forward regexp nil t)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2074 (save-excursion
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2075 (beginning-of-line)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2076 (if (not (= (char-after) ?X))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2077 (progn
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2078 (looking-at "\\([0-9]+\\).\\([0-9]+\\)")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2079 (setq line (match-string 1)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2080 column (match-string 2))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2081 (re-search-backward "^X [0-9]+ \\(.*\\)$")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2082 (set 'file (list (match-string 1) line column))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2083
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2084 ;; There could be duplicate choices, because of the structure
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2085 ;; of the .ali files
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2086 (unless (member file list)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2087 (set 'list (append list (list file))))))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2088
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2089 ;; Current buffer is still "*grep*"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2090 (kill-buffer "*grep*")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2091 )
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2092
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2093 ;; Now display the list of possible matches
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2094 (cond
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2095
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2096 ;; No choice found => Error
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2097 ((null list)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2098 (error "No cross-reference found, please recompile your file"))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2099
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2100 ;; Only one choice => Do the cross-reference
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2101 ((= (length list) 1)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2102 (set 'file (ada-find-src-file-in-dir (caar list)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2103 (if file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2104 (ada-xref-change-buffer file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2105 (string-to-number (nth 1 (car list)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2106 (string-to-number (nth 2 (car list)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2107 identlist
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2108 other-frame)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2109 (error (concat (caar list) " not found in src_dir")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2110 (message "This is only a (good) guess at the cross-reference.")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2111 )
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2112
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2113 ;; Else, ask the user
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2114 (t
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2115 (save-window-excursion
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2116 (with-output-to-temp-buffer "*choice list*"
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2117
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2118 (princ "Identifier is overloaded and Xref information is not up to date.\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2119 (princ "Possible declarations are:\n\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2120 (princ " no. in file at line col\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2121 (princ " --- --------------------- ---- ----\n")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2122 (let ((counter 0))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2123 (while (< counter (length list))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2124 (princ (format " %2d) %-21s %4s %4s\n"
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2125 (1+ counter)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2126 (nth 0 (nth counter list))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2127 (nth 1 (nth counter list))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2128 (nth 2 (nth counter list))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2129 ))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2130 (setq counter (1+ counter))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2131 )))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2132 (setq choice nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2133 (while (or (not choice)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2134 (not (integerp choice))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2135 (< choice 1)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2136 (> choice (length list)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2137 (setq choice
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2138 (string-to-int
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2139 (read-from-minibuffer "Enter No. of your choice: "))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2140 )
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2141 (set 'choice (1- choice))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2142 (kill-buffer "*choice list*")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2143
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2144 (set 'file (ada-find-src-file-in-dir (car (nth choice list))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2145 (if file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2146 (ada-xref-change-buffer file
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2147 (string-to-number (nth 1 (nth choice list)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2148 (string-to-number (nth 2 (nth choice list)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2149 identlist
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2150 other-frame)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2151 (error (concat (car (nth choice list)) " not found in src_dir")))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2152 (message "This is only a (good) guess at the cross-reference.")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2153 ))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2154
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2155 (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
2156 (file line column identlist &optional other-frame)
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2157 "Select and display FILE, at LINE and COLUMN.
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2158 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
2159 match. Kills the .ali buffer at the end.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
2160 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
2161
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2162 (let (declaration-buffer)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2163
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2164 ;; 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
2165 (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
2166 (if other-frame
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2167 (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
2168 (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
2169 (set-buffer declaration-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2170 (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
2171 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2172 (find-file file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2173 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2174
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2175 ;; 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
2176 (push-mark)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2177 (goto-line line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2178 (move-to-column column)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2179
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2180 ;; 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
2181 ;; 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
2182 ;; 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
2183 (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
2184 (ada-xref-search-nearest (ada-name-of identlist)))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2185 ))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2186
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2187
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2188 (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
2189 "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
2190 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
2191 (let ((orgpos (point))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2192 (newpos nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2193 (diff nil))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2194
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2195 (goto-char (point-max))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2196
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2197 ;; 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
2198 (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
2199
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2200 ;; 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
2201 (if (and
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2202 (not (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2203 (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
2204 (looking-at "_")))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2205 (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
2206 (or
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2207 ;; variable declaration ?
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2208 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2209 (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
2210 (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
2211 (looking-at ":[^=]"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2212 ;; 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
2213 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2214 (ada-goto-previous-word)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2215 (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
2216
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2217 ;; 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
2218 (if (or (not diff)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2219 (< (abs (- (point) orgpos)) diff))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2220 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2221 (setq newpos (point)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2222 diff (abs (- newpos orgpos))))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2223 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2224
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2225 (if newpos
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2226 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2227 (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
2228 (goto-char newpos))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2229 nil)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2230
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2231
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2232 ;; 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
2233 (defun ada-goto-parent ()
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
2234 "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
2235 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2236 (ada-require-project-file)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2237
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2238 (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
2239 (unit-name nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2240 (body-name nil)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2241 (ali-name nil))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2242 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2243 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2244 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2245 (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
2246 (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
2247 (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
2248 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2249 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2250 (error "No parent unit !"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2251 (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
2252 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2253
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2254 ;; 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
2255 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2256 (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
2257 "%s[ \t]+\\([^ \t]+\\)[ \t]+"
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2258 "\\([^ \t\n]+\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2259 (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
2260 (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
2261 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2262 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2263
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2264 (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
2265
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2266 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2267 ;; 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
2268 (if ali-name
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2269 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2270 (find-file ali-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2271 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2272 (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
2273 "\\([^ \t]+\\)"))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2274 (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
2275 (kill-buffer (current-buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2276 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2277 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2278 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2279
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2280 (find-file body-name)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2281 ))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2282
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2283 (defun ada-make-filename-from-adaname (adaname)
26227
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
2284 "Determine the filename in which ADANAME is found.
1be4a89d81d3 Doc-string fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 25899
diff changeset
2285 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
2286 (let (krunch-buf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2287 (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
2288 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2289 (set-buffer krunch-buf)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2290 ;; 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
2291 (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
2292 adaname ada-krunch-args)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2293 ;; 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
2294 (setq adaname (buffer-substring
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2295 (point-min)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2296 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2297 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2298 (end-of-line)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2299 (point))))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2300 (kill-buffer krunch-buf)))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2301 adaname
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2302 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2303
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2304 (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
2305 "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
2306 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
2307 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
2308 (interactive)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2309
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2310 (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
2311
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2312 ;; If the current buffer is the body (as is the case when calling this
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2313 ;; function from ff-file-created-hooks), then kill this temporary buffer
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2314 (unless (interactive-p)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2315 (progn
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2316 (set-buffer-modified-p nil)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2317 (kill-buffer (current-buffer))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47745
diff changeset
2318
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2319
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2320 ;; Make sure the current buffer is the spec (this might not be the case
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2321 ;; if for instance the user was asked for a project file)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2322
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2323 (unless (buffer-file-name (car (buffer-list)))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2324 (set-buffer (cadr (buffer-list))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2325
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2326 ;; Make sure we have a project file (for parameters to gnatstub). Note that
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2327 ;; this might have already been done if we have been called from the hook,
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2328 ;; but this is not an expensive call)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2329 (ada-require-project-file)
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2330
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2331 ;; 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
2332 (let* ((gnatstub-opts (ada-treat-cmd-string ada-gnatstub-opts))
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2333 (filename (buffer-file-name (car (buffer-list))))
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2334 (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
2335 (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
2336 (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
2337
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2338 (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2339 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2340 (compilation-minor-mode 1)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2341 (erase-buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2342 (insert gnatstub-cmd)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2343 (newline)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2344 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2345 ;; 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
2346 (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
2347
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2348 (if (save-excursion
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2349 (set-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2350 (goto-char (point-min))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2351 (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
2352 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2353 (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
2354 (sleep-for 2)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2355 (kill-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2356 (ada-make-body))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2357
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2358 ;; 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
2359
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2360 (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
2361 (progn
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2362 (find-file output)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2363 (kill-buffer buffer))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2364
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2365 ;; display the error buffer
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2366 (display-buffer buffer)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2367 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2368 )))
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2369
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2370 (defun ada-xref-initialize ()
38441
ceb40bd97a77 (ada-xref-initialize): Fix call to add-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38422
diff changeset
2371 "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
2372 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
2373 find-file...."
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2374 (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
2375 ;; 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
2376 (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
2377
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2378 ;; 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
2379 (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
2380 )
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2381
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2382
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2383 ;; ----- 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
2384
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2385 ;; Use gvd or ddd as the default debugger if it was found
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2386 ;; On windows, do not use the --tty switch for GVD, since this is
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2387 ;; not supported. Actually, we do not use this on Unix either, since otherwise
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2388 ;; there is no console window left in GVD, and people have to use the
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2389 ;; Emacs one.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2390 ;; This must be done before initializing the Ada menu.
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2391 (if (ada-find-file-in-dir "gvd" exec-path)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2392 (set 'ada-prj-default-debugger "gvd ")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2393 (if (ada-find-file-in-dir "gvd.exe" exec-path)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2394 (set 'ada-prj-default-debugger "gvd ")
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2395 (if (ada-find-file-in-dir "ddd" exec-path)
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2396 (set 'ada-prj-default-debugger "ddd --tty -fullname -toolbar"))))
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2397
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2398 ;; 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
2399 ;; 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
2400 (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
2401 (ada-add-keymap)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2402
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2403 (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
2404
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
2405 ;; Initializes the cross references to the runtime library
44466
f200fce92816 ada-mode no longer supports a different
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38441
diff changeset
2406 (ada-initialize-runtime-library "")
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
2407
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
2408 ;; 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
2409 (set 'ada-search-directories
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
2410 (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
2411 ada-search-directories))
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
2412
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
2413 ;; 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
2414 ;; 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
2415 ;; casing exceptions), it has to be read before the user edits a file).
45930
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
2416 ;; (add-hook 'ada-mode-hook
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
2417 ;; (lambda()
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
2418 ;; (let ((file (ada-prj-find-prj-file t)))
dd1d952f59c2 Update copyright notice.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44909
diff changeset
2419 ;; (if file (ada-reread-prj-file file)))))
30408
e3e2c9051c5f Got rid of all byte-compiler warnings on Emacs.
Gerd Moellmann <gerd@gnu.org>
parents: 26227
diff changeset
2420
25899
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2421 (provide 'ada-xref)
e5e3310746eb New file. Use Gnat for lookup and completion in Ada mode
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2422
32301
0f1f7e931493 Fix header line, copyright notice.
Dave Love <fx@gnu.org>
parents: 30408
diff changeset
2423 ;;; ada-xref.el ends here