;; ada-xref.el --- for lookup and completion in Ada mode
;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
;; Rolf Ebert <ebert@inf.enst.fr>
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; This Package provides a set of functions to use the output of the
:type 'string :group 'ada)
(defcustom ada-gnatls-args '("-v")
- "*Arguments to pass to `gnatfind' to find location of the runtime.
+ "*Arguments to pass to `gnatls' to find location of the runtime.
Typical use is to pass `--RTS=soft-floats' on some systems that support it.
You can also add `-I-' if you do not want the current directory to be included.
(reverse ada-xref-runtime-library-ali-path))
))
-
(defun ada-treat-cmd-string (cmd-string)
"Replace meta-sequences like ${...} in CMD-STRING with the appropriate value.
Assumes project exists.
;; Check if there is an environment variable with the same name
(if (null value)
(if (not (setq value (getenv name)))
- (message "%s" (concat "No environment variable " name " found"))))
+ (message "%s" (concat "No project or environment variable " name " found"))))
(cond
((null value)
Completion is attempted in all the directories in the source path, as
defined in the project file."
;; FIXME: doc arguments
+
+ ;; This function is not itself interactive, but it is called as part
+ ;; of the prompt of interactive functions, so we require a project
+ ;; file.
+ (ada-require-project-file)
(let (list
(dirs (ada-xref-get-src-dir-field)))
(let ((file (ada-find-src-file-in-dir filename)))
(if file
(find-file file)
- (error (concat filename " not found in src_dir")))))
+ (error "%s not found in src_dir" filename))))
;; ----- Utilities -------------------------------------------------
(defun ada-convert-file-name (name)
"Convert from NAME to a name that can be used by the compilation commands.
-This is overriden on VMS to convert from VMS filenames to Unix filenames."
+This is overridden on VMS to convert from VMS filenames to Unix filenames."
name)
;; FIXME: use convert-standard-filename instead
(let (selected)
- (if (or (not (string= mode-name "Ada"))
- (not (buffer-file-name)))
+ (if (not (and (derived-mode-p 'ada-mode)
+ buffer-file-name))
;; Not in an Ada buffer, or current buffer not associated
;; with a file (for instance an emerge buffer)
ada-prj-file-extension))
(dir (file-name-directory current-file))
- ;; on Emacs 20.2, directory-files does not work if
- ;; parse-sexp-lookup-properties is set
- (parse-sexp-lookup-properties nil)
(prj-files (directory-files
dir t
(concat ".*" (regexp-quote
(interactive "d\nP")
(ada-find-references pos arg t))
+(defconst ada-gnatfind-buffer-name "*gnatfind*")
+
(defun ada-find-any-references
(entity &optional file line column local-only append)
"Search for references to any entity whose name is ENTITY.
(setq command (concat command " -P" ada-prj-default-project-file))
(setq command (concat command " -p" ada-prj-default-project-file))))
- (if (and append (get-buffer "*gnatfind*"))
+ (if (and append (get-buffer ada-gnatfind-buffer-name))
(save-excursion
(set-buffer "*gnatfind*")
(setq old-contents (buffer-string))))
(let ((compilation-error "reference"))
- (compilation-start command))
+ (compilation-start command 'compilation-mode (lambda (mode) ada-gnatfind-buffer-name)))
;; Hide the "Compilation" menu
(save-excursion
- (set-buffer "*gnatfind*")
+ (set-buffer ada-gnatfind-buffer-name)
(local-unset-key [menu-bar compilation-menu])
(if old-contents
(progn
(goto-char 1)
+ (set 'buffer-read-only nil)
(insert old-contents)
+ (set 'buffer-read-only t)
(goto-char (point-max)))))
)
)
(beginning-of-line)
;; while we have a continuation line, go up one line
(while (looking-at "^\\.")
- (previous-line 1)
+ (forward-line -1)
(beginning-of-line))
(unless (looking-at (concat "[0-9]+.[0-9]+[ *]"
(ada-name-of identlist) "[ <{=\(\[]"))
;; No more idea to find the declaration. Give up
(progn
(kill-buffer ali-buffer)
- (error (concat "No declaration of " (ada-name-of identlist)
- " found."))
+
+ (error "No declaration of %s found." (ada-name-of identlist))
)))
)
(let ((current-line (buffer-substring
(point) (save-excursion (end-of-line) (point)))))
(save-excursion
- (next-line 1)
+ (forward-line 1)
(beginning-of-line)
(while (looking-at "^\\.\\(.*\\)")
(set 'current-line (concat current-line (match-string 1)))
- (next-line 1))
+ (forward-line 1))
)
(if (re-search-backward "^X [0-9]+ \\([a-zA-Z0-9_.-]+\\)" nil t)
;; none => error
((= len 0)
(kill-buffer (current-buffer))
- (error (concat "No declaration of "
- (ada-name-of identlist)
- " recorded in .ali file")))
-
+ (error "No declaration of %s recorded in .ali file"
+ (ada-name-of identlist)))
;; one => should be the right one
((= len 1)
(goto-line (caar declist)))
anywhere in the object path.
This command requires the external `egrep' program to be available.
-This works well when one is using an external librarie and wants to find
+This works well when one is using an external library and wants to find
the declaration and documentation of the subprograms one is using."
;; FIXME: what does this function do?
(let (list
(string-to-number (nth 2 (car list)))
identlist
other-frame)
- (error (concat (caar list) " not found in src_dir")))
+ (error "%s not found in src_dir" (caar list)))
(message "This is only a (good) guess at the cross-reference.")
)
(provide 'ada-xref)
-;;; arch-tag: 415a39fe-577b-4676-b3b1-6ff6db7ca24e
+;; arch-tag: 415a39fe-577b-4676-b3b1-6ff6db7ca24e
;;; ada-xref.el ends here