annotate lisp/progmodes/ada-xref.el @ 27231:e9725bb98b6e

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