annotate lisp/progmodes/ada-xref.el @ 61183:20df42e1599e

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