]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/ada-xref.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / progmodes / ada-xref.el
index 9c239ee6dbb54fdf22b06edd6a6f6ec231fed340..cea783e60bbd82424fc407752649ffb2bac8913b 100644 (file)
@@ -1,7 +1,7 @@
 ;; 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
@@ -22,9 +22,7 @@
 ;; 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
@@ -71,7 +69,7 @@ Set to 0, if you don't use crunched filenames.  This should be a string."
   :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.
@@ -322,7 +320,6 @@ CROSS-PREFIX is the prefix to use for the `gnatls' command."
         (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.
@@ -345,7 +342,7 @@ replaced by the name including the extension."
       ;; 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)
@@ -535,6 +532,11 @@ All the directories are returned as absolute directories."
 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)))
 
@@ -560,7 +562,7 @@ Completion is available."
   (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 -------------------------------------------------
@@ -613,7 +615,7 @@ If NO-USER-QUESTION, don't prompt user for file.  Call
 
 (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
 
@@ -644,8 +646,8 @@ is non-nil, prompt the user to select one.  If none are found, return
 
   (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)
@@ -663,9 +665,6 @@ is non-nil, prompt the user to select one.  If none are found, return
                            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
@@ -905,6 +904,8 @@ If ARG is t, the contents of the old *gnatfind* buffer is preserved."
   (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.
@@ -943,23 +944,25 @@ buffer `*gnatfind*', if there is one."
            (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)))))
     )
   )
@@ -1701,7 +1704,7 @@ Information is extracted from the ali file."
            (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) "[ <{=\(\[]"))
@@ -1717,8 +1720,8 @@ Information is extracted from the ali file."
          ;; 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))
            )))
       )
 
@@ -1730,11 +1733,11 @@ Information is extracted from the ali file."
        (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)
@@ -1803,10 +1806,8 @@ This function is disabled for operators, and only works for identifiers."
           ;; 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)))
@@ -1940,7 +1941,7 @@ This function attempts to find the possible declarations for the identifier
 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
@@ -2006,7 +2007,7 @@ the declaration and documentation of the subprograms one is using."
                                  (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.")
       )
 
@@ -2307,5 +2308,5 @@ For instance, it creates the gnat-specific menus, sets some hooks for
 
 (provide 'ada-xref)
 
-;;; arch-tag: 415a39fe-577b-4676-b3b1-6ff6db7ca24e
+;; arch-tag: 415a39fe-577b-4676-b3b1-6ff6db7ca24e
 ;;; ada-xref.el ends here