]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/ada-xref.el
Update copyright year to 2015
[gnu-emacs] / lisp / progmodes / ada-xref.el
index 146cc703e1a78a69bea14165f1b4f90d32af0f41..6b611e6f99b15ec5ea32e698e06a93441affccf6 100644 (file)
@@ -1,6 +1,6 @@
 ;; ada-xref.el --- for lookup and completion in Ada mode
 
-;; Copyright (C) 1994-201 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2015 Free Software Foundation, Inc.
 
 ;; Author: Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
 ;;      Rolf Ebert <ebert@inf.enst.fr>
@@ -342,9 +342,9 @@ CROSS-PREFIX is the prefix to use for the `gnatls' command."
                )
            (kill-buffer nil))))
 
-    (set 'ada-xref-runtime-library-specs-path
+    (setada-xref-runtime-library-specs-path
         (reverse ada-xref-runtime-library-specs-path))
-    (set 'ada-xref-runtime-library-ali-path
+    (setada-xref-runtime-library-ali-path
         (reverse ada-xref-runtime-library-ali-path))
     ))
 
@@ -582,8 +582,8 @@ as defined in the project file."
 
     (while dirs
       (if (file-directory-p (car dirs))
-         (set 'list (append list (file-name-all-completions string (car dirs)))))
-      (set 'dirs (cdr dirs)))
+         (setlist (append list (file-name-all-completions string (car dirs)))))
+      (setdirs (cdr dirs)))
     (cond ((equal flag 'lambda)
           (assoc string list))
          (flag
@@ -651,12 +651,6 @@ Call `ada-require-project-file' first to ensure a project exists."
        (find-file (car (cdr pos)))
        (goto-char (car pos)))))
 
-(defun ada-convert-file-name (name)
-  "Convert from NAME to a name that can be used by the compilation commands.
-This is overridden on VMS to convert from VMS filenames to Unix filenames."
-  name)
-;; FIXME: use convert-standard-filename instead
-
 (defun ada-set-default-project-file (file)
   "Set FILE as the current project file."
   (interactive "fProject file:")
@@ -702,11 +696,11 @@ is non-nil, prompt the user to select one.  If none are found, return
 
         ((file-exists-p first-choice)
          ;; filename.adp
-         (set 'selected first-choice))
+         (setselected first-choice))
 
         ((= (length prj-files) 1)
          ;; Exactly one project file was found in the current directory
-         (set 'selected (car prj-files)))
+         (setselected (car prj-files)))
 
         ((and (> (length prj-files) 1) (not no-user-question))
          ;;  multiple project files in current directory, ask the user
@@ -732,7 +726,7 @@ is non-nil, prompt the user to select one.  If none are found, return
                    (> choice (length prj-files)))
              (setq choice (string-to-number
                            (read-from-minibuffer "Enter No. of your choice: "))))
-           (set 'selected (nth (1- choice) prj-files))))
+           (setselected (nth (1- choice) prj-files))))
 
         ((= (length prj-files) 0)
          ;; No project file in the current directory; ask user
@@ -742,7 +736,7 @@ is non-nil, prompt the user to select one.  If none are found, return
                   (concat "project file [" ada-last-prj-file "]:")
                   nil ada-last-prj-file))
            (unless (string= ada-last-prj-file "")
-             (set 'selected ada-last-prj-file))))
+             (setselected ada-last-prj-file))))
         )))
 
     (or selected "default.adp")
@@ -792,9 +786,9 @@ is non-nil, prompt the user to select one.  If none are found, return
 
     (setq prj-file (expand-file-name prj-file))
     (if (string= (file-name-extension prj-file) "gpr")
-       (set 'project (ada-gnat-parse-gpr project prj-file))
+       (setproject (ada-gnat-parse-gpr project prj-file))
 
-      (set 'project (ada-parse-prj-file-1 prj-file project))
+      (setproject (ada-parse-prj-file-1 prj-file project))
       )
 
     ;; Store the project properties
@@ -842,7 +836,7 @@ Return new value of PROJECT."
                          (substitute-in-file-name (match-string 2)))))
 
           ((string= (match-string 1) "build_dir")
-           (set 'project
+           (setproject
                 (plist-put project 'build_dir
                            (file-name-as-directory (match-string 2)))))
 
@@ -884,7 +878,7 @@ Return new value of PROJECT."
 
           (t
            ;; any other field in the file is just copied
-           (set 'project (plist-put project
+           (setproject (plist-put project
                                     (intern (match-string 1))
                                     (match-string 2))))))
 
@@ -900,21 +894,21 @@ Return new value of PROJECT."
        (let ((sep (plist-get project 'ada_project_path_sep)))
          (setq ada_project_path (reverse ada_project_path))
          (setq ada_project_path (mapconcat 'identity ada_project_path sep))
-         (set 'project (plist-put project 'ada_project_path ada_project_path))
+         (setproject (plist-put project 'ada_project_path ada_project_path))
          ;; env var needed now for ada-gnat-parse-gpr
          (setenv "ADA_PROJECT_PATH" ada_project_path)))
 
-    (if debug_post_cmd (set 'project (plist-put project 'debug_post_cmd (reverse debug_post_cmd))))
-    (if debug_pre_cmd (set 'project (plist-put project 'debug_pre_cmd (reverse debug_pre_cmd))))
-    (if casing (set 'project (plist-put project 'casing (reverse casing))))
-    (if check_cmd (set 'project (plist-put project 'check_cmd (reverse check_cmd))))
-    (if comp_cmd (set 'project (plist-put project 'comp_cmd (reverse comp_cmd))))
-    (if make_cmd (set 'project (plist-put project 'make_cmd (reverse make_cmd))))
-    (if run_cmd (set 'project (plist-put project 'run_cmd (reverse run_cmd))))
+    (if debug_post_cmd (setproject (plist-put project 'debug_post_cmd (reverse debug_post_cmd))))
+    (if debug_pre_cmd (setproject (plist-put project 'debug_pre_cmd (reverse debug_pre_cmd))))
+    (if casing (setproject (plist-put project 'casing (reverse casing))))
+    (if check_cmd (setproject (plist-put project 'check_cmd (reverse check_cmd))))
+    (if comp_cmd (setproject (plist-put project 'comp_cmd (reverse comp_cmd))))
+    (if make_cmd (setproject (plist-put project 'make_cmd (reverse make_cmd))))
+    (if run_cmd (setproject (plist-put project 'run_cmd (reverse run_cmd))))
 
     (if gpr_file
        (progn
-         (set 'project (ada-gnat-parse-gpr project gpr_file))
+         (setproject (ada-gnat-parse-gpr project gpr_file))
          ;; append Ada source and object directories to others from Emacs project file
          (setq src_dir (append (plist-get project 'src_dir) src_dir))
          (setq obj_dir (append (plist-get project 'obj_dir) obj_dir))
@@ -930,8 +924,8 @@ Return new value of PROJECT."
     (ada-initialize-runtime-library (or (ada-xref-get-project-field 'cross_prefix) ""))
     ;;)
 
-    (if obj_dir (set 'project (plist-put project 'obj_dir (reverse obj_dir))))
-    (if src_dir (set 'project (plist-put project 'src_dir (reverse src_dir))))
+    (if obj_dir (setproject (plist-put project 'obj_dir (reverse obj_dir))))
+    (if src_dir (setproject (plist-put project 'src_dir (reverse src_dir))))
 
     project
     ))
@@ -1052,9 +1046,9 @@ existing buffer `*gnatfind*', if there is one."
       (if old-contents
          (progn
            (goto-char 1)
-           (set 'buffer-read-only nil)
+           (setbuffer-read-only nil)
            (insert old-contents)
-           (set 'buffer-read-only t)
+           (setbuffer-read-only t)
            (goto-char (point-max)))))
     )
   )
@@ -1142,7 +1136,7 @@ If OTHER-FRAME is non-nil, display the cross-reference in another frame."
     (condition-case err
        (ada-find-in-ali identlist other-frame)
       ;; File not found: print explicit error message
-      (error-file-not-found
+      (ada-error-file-not-found
        (message (concat (error-message-string err)
                        (nthcdr 1 err))))
 
@@ -1194,9 +1188,9 @@ project file."
        (objects   (getenv "ADA_OBJECTS_PATH"))
        (build-dir (ada-xref-get-project-field 'build_dir)))
     (if include
-       (set 'include (concat path-separator include)))
+       (setinclude (concat path-separator include)))
     (if objects
-       (set 'objects (concat path-separator objects)))
+       (setobjects (concat path-separator objects)))
     (cons
      (concat "ADA_INCLUDE_PATH="
             (mapconcat (lambda(x) (expand-file-name x build-dir))
@@ -1303,7 +1297,7 @@ If ARG is non-nil, ask for user confirmation."
 
     ;;  Guess the command if it wasn't specified
     (if (not command)
-       (set 'command (list (file-name-sans-extension (buffer-name)))))
+       (setcommand (list (file-name-sans-extension (buffer-name)))))
 
     ;; Modify the command to run remotely
     (setq command (ada-remote (mapconcat 'identity command
@@ -1316,7 +1310,7 @@ If ARG is non-nil, ask for user confirmation."
 
     ;; Run the command
     (with-current-buffer (get-buffer-create "*run*")
-      (set 'buffer-read-only nil)
+      (setbuffer-read-only nil)
 
       (erase-buffer)
       (start-process "run" (current-buffer) shell-file-name
@@ -1352,7 +1346,7 @@ project file."
 
     ;;  If the command was not given in the project file, start a bare gdb
     (if (not cmd)
-       (set 'cmd (concat ada-prj-default-debugger
+       (setcmd (concat ada-prj-default-debugger
                          " "
                          (or executable-name
                              (file-name-sans-extension (buffer-file-name))))))
@@ -1368,18 +1362,18 @@ project file."
        ;;  chance to fully manage it.  Then it works fine with Enlightenment
        ;;  as well
        (let ((frame (make-frame '((visibility . nil)))))
-         (set 'cmd (concat
+         (setcmd (concat
                     cmd " --editor-window="
                     (cdr (assoc 'outer-window-id (frame-parameters frame)))))
          (select-frame frame)))
 
     ;;  Add a -fullname switch
     ;;  Use the remote machine
-    (set 'cmd (ada-remote (concat cmd " -fullname ")))
+    (setcmd (ada-remote (concat cmd " -fullname ")))
 
     ;;  Ask for confirmation if required
     (if (or arg ada-xref-confirm-compile)
-       (set 'cmd (read-from-minibuffer "enter command to debug: " cmd)))
+       (setcmd (read-from-minibuffer "enter command to debug: " cmd)))
 
     (let ((old-comint-exec (symbol-function 'comint-exec)))
 
@@ -1387,13 +1381,13 @@ project file."
       ;;  FIXME: This is evil but luckily a nop under Emacs-21.3.50 !  -stef
       (fset 'gud-gdb-massage-args (lambda (_file args) args))
 
-      (set 'pre-cmd  (mapconcat 'identity pre-cmd  ada-command-separator))
+      (setpre-cmd  (mapconcat 'identity pre-cmd  ada-command-separator))
       (if (not (equal pre-cmd ""))
          (setq pre-cmd (concat pre-cmd ada-command-separator)))
 
-      (set 'post-cmd (mapconcat 'identity post-cmd "\n"))
+      (setpost-cmd (mapconcat 'identity post-cmd "\n"))
       (if post-cmd
-         (set 'post-cmd (concat post-cmd "\n")))
+         (setpost-cmd (concat post-cmd "\n")))
 
 
       ;;  Temporarily replaces the definition of `comint-exec' so that we
@@ -1403,7 +1397,7 @@ project file."
            `(lambda (buffer name command startfile switches)
               (let (compilation-buffer-name-function)
                 (save-excursion
-                  (set 'compilation-buffer-name-function
+                  (setcompilation-buffer-name-function
                        (lambda(x) (buffer-name buffer)))
                   (compile (ada-quote-cmd
                             (concat ,pre-cmd
@@ -1465,7 +1459,7 @@ by replacing the file extension with `.ali'."
           (get-file-buffer ali-file-name))
       (kill-buffer (get-file-buffer ali-file-name)))
 
-  (let* ((name      (ada-convert-file-name file))
+  (let* ((name      (convert-standard-filename file))
         (body-name (or (ada-get-body-name name) name)))
 
     ;; Always recompile the body when we can.  We thus temporarily switch to a
@@ -1498,12 +1492,12 @@ by replacing the file extension with `.ali'."
   "Search for FILE in DIR-LIST."
   (let (found)
     (while (and (not found) dir-list)
-      (set 'found (concat (file-name-as-directory (car dir-list))
+      (setfound (concat (file-name-as-directory (car dir-list))
                          (file-name-nondirectory file)))
 
       (unless (file-exists-p found)
-         (set 'found nil))
-      (set 'dir-list (cdr dir-list)))
+         (setfound nil))
+      (setdir-list (cdr dir-list)))
     found))
 
 (defun ada-find-ali-file-in-dir (file)
@@ -1544,9 +1538,7 @@ the project file."
   ;;      also a separate.
 
   (with-current-buffer (get-file-buffer file)
-    (let ((short-ali-file-name
-          (concat (file-name-sans-extension (file-name-nondirectory file))
-                  ".ali"))
+    (let ((short-ali-file-name (concat (file-name-base file) ".ali"))
          ali-file-name
          is-spec)
 
@@ -1560,16 +1552,13 @@ the project file."
            (while specs
              (if (string-match (concat (regexp-quote (car specs)) "$")
                                file)
-                 (set 'is-spec t))
-             (set 'specs (cdr specs)))))
+                 (setis-spec t))
+             (setspecs (cdr specs)))))
 
       (if is-spec
-         (set 'ali-file-name
+         (setali-file-name
               (ada-find-ali-file-in-dir
-               (concat (file-name-sans-extension
-                        (file-name-nondirectory
-                         (ada-other-file-name)))
-                       ".ali"))))
+               (concat (file-name-base (ada-other-file-name)) ".ali"))))
 
 
       (setq ali-file-name
@@ -1584,21 +1573,18 @@ the project file."
                ;;  file_s.ada and file_b.ada), try to go to the other file
                ;;  and look for its ali file
                (ada-find-ali-file-in-dir
-                (concat (file-name-sans-extension
-                         (file-name-nondirectory (ada-other-file-name)))
-                        ".ali"))
+                (concat (file-name-base (ada-other-file-name)) ".ali"))
 
 
                ;;  If we still don't have an ali file, try to get the one
                ;;  from the parent unit, in case we have a separate entity.
-               (let ((parent-name (file-name-sans-extension
-                                   (file-name-nondirectory file))))
+               (let ((parent-name (file-name-base file)))
 
                  (while (and (not ali-file-name)
                              (string-match "^\\(.*\\)[.-][^.-]*" parent-name))
 
-                   (set 'parent-name (match-string 1 parent-name))
-                   (set 'ali-file-name (ada-find-ali-file-in-dir
+                   (setparent-name (match-string 1 parent-name))
+                   (setali-file-name (ada-find-ali-file-in-dir
                                         (concat parent-name ".ali")))
                    )
                  ali-file-name)))
@@ -1645,7 +1631,7 @@ Search in project file for possible paths."
     (let ((filename (ada-find-src-file-in-dir file)))
       (if filename
          (expand-file-name filename)
-       (signal 'error-file-not-found (file-name-nondirectory file)))
+       (signal 'ada-error-file-not-found (file-name-nondirectory file)))
       )))
 
 (defun ada-find-file-number-in-ali (file)
@@ -1694,18 +1680,18 @@ macros `ada-name-of', `ada-line-of', `ada-column-of', `ada-file-of',..."
          (if (and (= (char-before) ?\")
                   (= (char-after (+ (length (match-string 0)) (point))) ?\"))
              (forward-char -1))
-         (set 'identifier (regexp-quote (concat "\"" (match-string 0) "\""))))
+         (setidentifier (regexp-quote (concat "\"" (match-string 0) "\""))))
 
       (if (ada-in-string-p)
          (error "Inside string or character constant"))
       (if (looking-at (concat ada-keywords "[^a-zA-Z_]"))
          (error "No cross-reference available for reserved keyword"))
       (if (looking-at "[a-zA-Z0-9_]+")
-         (set 'identifier (match-string 0))
+         (setidentifier (match-string 0))
        (error "No identifier around")))
 
     ;; Build the identlist
-    (set 'identlist    (ada-make-identlist))
+    (setidentlist    (ada-make-identlist))
     (ada-set-name      identlist (downcase identifier))
     (ada-set-line      identlist
                       (number-to-string (count-lines 1 (point))))
@@ -1733,7 +1719,7 @@ Information is extracted from the ali file."
         (concat "^X [0-9]+ " (file-name-nondirectory (ada-file-of identlist)))
         nil t)
        (let ((bound (save-excursion (re-search-forward "^X " nil t))))
-         (set 'declaration-found
+         (setdeclaration-found
               (re-search-forward
                (concat "^"    (ada-line-of identlist)
                        "."    (ada-column-of identlist)
@@ -1751,7 +1737,7 @@ Information is extracted from the ali file."
       ;; Since we already know the number of the file, search for a direct
       ;; reference to it
       (goto-char (point-min))
-      (set 'declaration-found t)
+      (setdeclaration-found t)
       (ada-set-ali-index
        identlist
        (number-to-string (ada-find-file-number-in-ali
@@ -1779,7 +1765,7 @@ Information is extracted from the ali file."
            ;; If still not found, then either the declaration is unknown
            ;; or the source file has been modified since the ali file was
            ;; created
-           (set 'declaration-found nil)
+           (setdeclaration-found nil)
            )
          )
 
@@ -1794,7 +1780,7 @@ Information is extracted from the ali file."
              (beginning-of-line))
            (unless (looking-at (concat "[0-9]+.[0-9]+[ *]"
                                        (ada-name-of identlist) "[ <{=\(\[]"))
-             (set 'declaration-found nil))))
+             (setdeclaration-found nil))))
 
       ;; Still no success ! The ali file must be too old, and we need to
       ;; use a basic algorithm based on guesses.  Note that this only happens
@@ -1802,7 +1788,7 @@ Information is extracted from the ali file."
       ;; automatically
       (unless declaration-found
        (if (ada-xref-find-in-modified-ali identlist)
-           (set 'declaration-found t)
+           (setdeclaration-found t)
          ;; No more idea to find the declaration.  Give up
          (progn
            (kill-buffer ali-buffer)
@@ -1822,7 +1808,7 @@ Information is extracted from the ali file."
            (forward-line 1)
            (beginning-of-line)
            (while (looking-at "^\\.\\(.*\\)")
-             (set 'current-line (concat current-line (match-string 1)))
+             (setcurrent-line (concat current-line (match-string 1)))
              (forward-line 1))
            )
 
@@ -1836,7 +1822,7 @@ Information is extracted from the ali file."
                                          (ada-file-of identlist)))
 
                ;;  Else clean up the ali file
-               (error-file-not-found
+               (ada-error-file-not-found
                 (signal (car err) (cdr err)))
                (error
                 (kill-buffer ali-buffer)
@@ -1868,7 +1854,7 @@ This function is disabled for operators, and only works for identifiers."
          (goto-char (point-max))
          (while (re-search-backward my-regexp nil t)
            (save-excursion
-             (set 'line-ali (count-lines 1 (point)))
+             (setline-ali (count-lines 1 (point)))
              (beginning-of-line)
              ;; have a look at the line and column numbers
              (if (looking-at "^\\([0-9]+\\).\\([0-9]+\\)[ *]")
@@ -1956,7 +1942,7 @@ opens a new window to show the declaration."
 
     ;; Get all the possible locations
     (string-match "^\\([0-9]+\\)[a-zA-Z+*]\\([0-9]+\\)[ *]" ali-line)
-    (set 'locations (list (list (match-string 1 ali-line) ;; line
+    (setlocations (list (list (match-string 1 ali-line) ;; line
                                (match-string 2 ali-line) ;; column
                                (ada-declare-file-of identlist))))
     (while (string-match "\\([0-9]+\\)[bc]\\(<[^>]+>\\)?\\([0-9]+\\)"
@@ -1976,16 +1962,16 @@ opens a new window to show the declaration."
            (goto-char (point-min))
            (re-search-forward "^D \\([a-zA-Z0-9_.-]+\\)" nil t
                               (string-to-number file-number))
-           (set 'file (match-string 1))
+           (setfile (match-string 1))
            )
        ;; Else get the nearest file
-       (set 'file (ada-declare-file-of identlist)))
+       (setfile (ada-declare-file-of identlist)))
 
-      (set 'locations (append locations (list (list line col file)))))
+      (setlocations (append locations (list (list line col file)))))
 
     ;; Add the specs at the end again, so that from the last body we go to
     ;; the specs
-    (set 'locations (append locations (list (car locations))))
+    (setlocations (append locations (list (car locations))))
 
     ;; Find the new location we want to go to.
     ;; If we are on none of the locations listed, we simply go to the specs.
@@ -2004,10 +1990,10 @@ opens a new window to show the declaration."
                col       (nth 1 locations)
                file      (nth 2 locations)
                locations nil)
-       (set 'locations (cdr locations))))
+       (setlocations (cdr locations))))
 
     ;;  Find the file in the source path
-    (set 'file (ada-get-ada-file-name file (ada-file-of identlist)))
+    (setfile (ada-get-ada-file-name file (ada-file-of identlist)))
 
     ;; Kill the .ali buffer
     (kill-buffer (current-buffer))
@@ -2052,10 +2038,10 @@ the declaration and documentation of the subprograms one is using."
                  " "
                  (shell-quote-argument (file-name-as-directory (car dirs)))
                  "*.ali")))
-       (set 'dirs (cdr dirs)))
+       (setdirs (cdr dirs)))
 
       ;;  Now parse the output
-      (set 'case-fold-search t)
+      (setcase-fold-search t)
       (goto-char (point-min))
       (while (re-search-forward regexp nil t)
        (save-excursion
@@ -2066,12 +2052,12 @@ the declaration and documentation of the subprograms one is using."
                (setq line   (match-string 1)
                      column (match-string 2))
                (re-search-backward "^X [0-9]+ \\(.*\\)$")
-               (set 'file (list (match-string 1) line column))
+               (setfile (list (match-string 1) line column))
 
                ;;  There could be duplicate choices, because of the structure
                ;;  of the .ali files
                (unless (member file list)
-                 (set 'list (append list (list file))))))))
+                 (setlist (append list (list file))))))))
 
       ;;  Current buffer is still "*grep*"
       (kill-buffer "*grep*")
@@ -2086,7 +2072,7 @@ the declaration and documentation of the subprograms one is using."
 
      ;;  Only one choice => Do the cross-reference
      ((= (length list) 1)
-      (set 'file (ada-find-src-file-in-dir (caar list)))
+      (setfile (ada-find-src-file-in-dir (caar list)))
       (if file
          (ada-xref-change-buffer file
                                  (string-to-number (nth 1 (car list)))
@@ -2125,17 +2111,17 @@ the declaration and documentation of the subprograms one is using."
                (string-to-number
                 (read-from-minibuffer "Enter No. of your choice: "))))
        )
-      (set 'choice (1- choice))
+      (setchoice (1- choice))
       (kill-buffer "*choice list*")
 
-      (set 'file (ada-find-src-file-in-dir (car (nth choice list))))
+      (setfile (ada-find-src-file-in-dir (car (nth choice list))))
       (if file
          (ada-xref-change-buffer file
                                  (string-to-number (nth 1 (nth choice list)))
                                  (string-to-number (nth 2 (nth choice list)))
                                  identlist
                                  other-frame)
-       (signal 'error-file-not-found (car (nth choice list))))
+       (signal 'ada-error-file-not-found (car (nth choice list))))
       (message "This is only a (good) guess at the cross-reference.")
       ))))
 
@@ -2152,7 +2138,7 @@ If OTHER-FRAME is non-nil, creates a new frame to show the file."
     (if ada-xref-other-buffer
        (if other-frame
            (find-file-other-frame file)
-         (set 'declaration-buffer (find-file-noselect file))
+         (setdeclaration-buffer (find-file-noselect file))
          (set-buffer declaration-buffer)
          (switch-to-buffer-other-window declaration-buffer)
          )
@@ -2370,12 +2356,8 @@ For instance, it creates the gnat-specific menus, sets some hooks for
 (add-hook 'ada-mode-hook 'ada-xref-initialize)
 
 ;;  Define a new error type
-(put 'error-file-not-found
-     'error-conditions
-     '(error ada-mode-errors error-file-not-found))
-(put 'error-file-not-found
-     'error-message
-     "File not found in src-dir (check project file): ")
+(define-error 'ada-error-file-not-found
+  "File not found in src-dir (check project file): " 'ada-mode-errors)
 
 (provide 'ada-xref)