annotate lisp/progmodes/ada-xref.el @ 112447:bcecab2ad22d

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