diff options
| author | Juanma Barranquero | 2006-11-12 17:06:31 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2006-11-12 17:06:31 +0000 |
| commit | 0262d5e1f4a666d2eab5836b4c3572516079839c (patch) | |
| tree | be3e055c54692f9256068dd6f487c5469e34ec44 | |
| parent | 3b5b1ad923aba876809951734ee0a0ab353ad346 (diff) | |
| download | emacs-0262d5e1f4a666d2eab5836b4c3572516079839c.tar.gz emacs-0262d5e1f4a666d2eab5836b4c3572516079839c.zip | |
(ada-prj-default-check-cmd): New variable, replacing deleted variable
`ada-check-switch'.
(ada-project-file-extension): Rename to `ada-prj-file-extension'.
(ada-xref-project-files): Improve doc string.
(ada-find-executable): New function.
(ada-initialize-runtime-library): Use `ada-find-executable'.
(ada-xref-set-default-prj-values): In compile commands, don't
need `ada-cd-command'; `compile' does that more portably.
Use ada-prj-default-check-cmd.
(ada-parse-prj-file): Don't set 'debug_post_cmd, 'debug_pre_cmd
properties if not specified in project file.
(ada-goto-declaration): Display useful message for new error
'error-file-not-found.
(ada-get-ada-file-name, ada-find-in-src-path): Signal new error
'error-file-not-found.
(ada-get-all-references): Match latest ali syntax.
Signal new error 'error-file-not-found.
(ada-find-in-ali): Match latest ali syntax.
(ada-make-filename-from-adaname): Handle different semantics
of gnatkr in GNAT 3.15p vs later.
| -rw-r--r-- | lisp/progmodes/ada-xref.el | 120 |
1 files changed, 77 insertions, 43 deletions
diff --git a/lisp/progmodes/ada-xref.el b/lisp/progmodes/ada-xref.el index c6fcc670038..1ee89027975 100644 --- a/lisp/progmodes/ada-xref.el +++ b/lisp/progmodes/ada-xref.el | |||
| @@ -104,6 +104,14 @@ The command `gnatfind' is used every time you choose the menu | |||
| 104 | \"Show all references\"." | 104 | \"Show all references\"." |
| 105 | :type 'string :group 'ada) | 105 | :type 'string :group 'ada) |
| 106 | 106 | ||
| 107 | (defcustom ada-prj-default-check-cmd | ||
| 108 | (concat "${cross_prefix}gnatmake -u -c -gnatc ${gnatmake_opt} ${full_current}" | ||
| 109 | " -cargs ${comp_opt}") | ||
| 110 | "*Default command to be used to compile a single file. | ||
| 111 | Emacs will substitute the current filename for ${full_current}, or add | ||
| 112 | the filename at the end. This is the same syntax as in the project file." | ||
| 113 | :type 'string :group 'ada) | ||
| 114 | |||
| 107 | (defcustom ada-prj-default-comp-cmd | 115 | (defcustom ada-prj-default-comp-cmd |
| 108 | (concat "${cross_prefix}gnatmake -u -c ${gnatmake_opt} ${full_current} -cargs" | 116 | (concat "${cross_prefix}gnatmake -u -c ${gnatmake_opt} ${full_current} -cargs" |
| 109 | " ${comp_opt}") | 117 | " ${comp_opt}") |
| @@ -171,10 +179,7 @@ file.") | |||
| 171 | (defvar ada-last-prj-file "" | 179 | (defvar ada-last-prj-file "" |
| 172 | "Name of the last project file entered by the user.") | 180 | "Name of the last project file entered by the user.") |
| 173 | 181 | ||
| 174 | (defvar ada-check-switch "-gnats" | 182 | (defconst ada-prj-file-extension ".adp" |
| 175 | "Switch added to the command line to check the current file.") | ||
| 176 | |||
| 177 | (defconst ada-project-file-extension ".adp" | ||
| 178 | "The extension used for project files.") | 183 | "The extension used for project files.") |
| 179 | 184 | ||
| 180 | (defvar ada-xref-runtime-library-specs-path '() | 185 | (defvar ada-xref-runtime-library-specs-path '() |
| @@ -210,10 +215,15 @@ we need to use `/d' or the drive is never changed.") | |||
| 210 | "Regexp to match for operators.") | 215 | "Regexp to match for operators.") |
| 211 | 216 | ||
| 212 | (defvar ada-xref-project-files '() | 217 | (defvar ada-xref-project-files '() |
| 213 | "Associative list of project files. | 218 | "Associative list of project files with properties. |
| 214 | It has the following format: | 219 | It has the format: (project project ...) |
| 215 | \((project_name . value) (project_name . value) ...) | 220 | A project has the format: (project-file . project-plist) |
| 216 | As always, the values of the project file are defined through properties.") | 221 | \(See 'apropos plist' for operations on property lists). See |
| 222 | ada-xref-set-default-prj-values for the list of valid properties. The | ||
| 223 | current project is retrieved with ada-xref-current-project. Properties | ||
| 224 | are retrieved with ada-xref-get-project-field, set with | ||
| 225 | ada-xref-set-project-field. If project properties are accessed with no | ||
| 226 | project file, a (nil . default-properties) entry is created.") | ||
| 217 | 227 | ||
| 218 | 228 | ||
| 219 | ;; ----- Identlist manipulation ------------------------------------------- | 229 | ;; ----- Identlist manipulation ------------------------------------------- |
| @@ -250,6 +260,13 @@ As always, the values of the project file are defined through properties.") | |||
| 250 | "Duplicate all \\ characters in CMD so that it can be passed to `compile'." | 260 | "Duplicate all \\ characters in CMD so that it can be passed to `compile'." |
| 251 | (mapconcat 'identity (split-string cmd "\\\\") "\\\\")) | 261 | (mapconcat 'identity (split-string cmd "\\\\") "\\\\")) |
| 252 | 262 | ||
| 263 | (defun ada-find-executable (exec-name) | ||
| 264 | "Find the full path to the executable file EXEC-NAME. | ||
| 265 | On Windows systems, this will properly handle .exe extension as well" | ||
| 266 | (or (ada-find-file-in-dir exec-name exec-path) | ||
| 267 | (ada-find-file-in-dir (concat exec-name ".exe") exec-path) | ||
| 268 | exec-name)) | ||
| 269 | |||
| 253 | (defun ada-initialize-runtime-library (cross-prefix) | 270 | (defun ada-initialize-runtime-library (cross-prefix) |
| 254 | "Initialize the variables for the runtime library location. | 271 | "Initialize the variables for the runtime library location. |
| 255 | CROSS-PREFIX is the prefix to use for the `gnatls' command." | 272 | CROSS-PREFIX is the prefix to use for the `gnatls' command." |
| @@ -264,8 +281,9 @@ CROSS-PREFIX is the prefix to use for the `gnatls' command." | |||
| 264 | ;; Even if we get an error, delete the *gnatls* buffer | 281 | ;; Even if we get an error, delete the *gnatls* buffer |
| 265 | (unwind-protect | 282 | (unwind-protect |
| 266 | (progn | 283 | (progn |
| 267 | (apply 'call-process (concat cross-prefix "gnatls") | 284 | (let ((gnatls |
| 268 | (append '(nil t nil) ada-gnatls-args)) | 285 | (ada-find-executable (concat cross-prefix "gnatls")))) |
| 286 | (apply 'call-process gnatls (append '(nil t nil) ada-gnatls-args))) | ||
| 269 | (goto-char (point-min)) | 287 | (goto-char (point-min)) |
| 270 | 288 | ||
| 271 | ;; Source path | 289 | ;; Source path |
| @@ -384,20 +402,13 @@ replaced by the name including the extension." | |||
| 384 | "") | 402 | "") |
| 385 | 'cross_prefix "" | 403 | 'cross_prefix "" |
| 386 | 'remote_machine "" | 404 | 'remote_machine "" |
| 387 | 'comp_cmd (list (concat ada-cd-command " ${build_dir}") | 405 | 'comp_cmd (list ada-prj-default-comp-cmd) |
| 388 | ada-prj-default-comp-cmd) | 406 | 'check_cmd (list ada-prj-default-check-cmd) |
| 389 | 'check_cmd (list (concat ada-prj-default-comp-cmd " " | 407 | 'make_cmd (list ada-prj-default-make-cmd) |
| 390 | ada-check-switch)) | 408 | 'run_cmd (list (concat "./${main}" (if is-windows ".exe"))) |
| 391 | 'make_cmd (list (concat ada-cd-command " ${build_dir}") | 409 | 'debug_pre_cmd (list (concat ada-cd-command " ${build_dir}")) |
| 392 | ada-prj-default-make-cmd) | ||
| 393 | 'run_cmd (list (concat ada-cd-command " ${build_dir}") | ||
| 394 | (concat "${main}" | ||
| 395 | (if is-windows ".exe"))) | ||
| 396 | 'debug_pre_cmd (list (concat ada-cd-command | ||
| 397 | " ${build_dir}")) | ||
| 398 | 'debug_cmd (concat ada-prj-default-debugger | 410 | 'debug_cmd (concat ada-prj-default-debugger |
| 399 | (if is-windows " ${main}.exe" | 411 | " ${main}" (if is-windows ".exe")) |
| 400 | " ${main}")) | ||
| 401 | 'debug_post_cmd (list nil))) | 412 | 'debug_post_cmd (list nil))) |
| 402 | ) | 413 | ) |
| 403 | (set symbol plist))) | 414 | (set symbol plist))) |
| @@ -494,7 +505,7 @@ All the directories are returned as absolute directories." | |||
| 494 | (ada-xref-update-project-menu)))) | 505 | (ada-xref-update-project-menu)))) |
| 495 | (vector | 506 | (vector |
| 496 | (if (string= (file-name-extension name) | 507 | (if (string= (file-name-extension name) |
| 497 | ada-project-file-extension) | 508 | ada-prj-file-extension) |
| 498 | (file-name-sans-extension | 509 | (file-name-sans-extension |
| 499 | (file-name-nondirectory name)) | 510 | (file-name-nondirectory name)) |
| 500 | (file-name-nondirectory name)) | 511 | (file-name-nondirectory name)) |
| @@ -628,7 +639,7 @@ file. If none is set, return nil." | |||
| 628 | (let* ((current-file (or file (buffer-file-name))) | 639 | (let* ((current-file (or file (buffer-file-name))) |
| 629 | (first-choice (concat | 640 | (first-choice (concat |
| 630 | (file-name-sans-extension current-file) | 641 | (file-name-sans-extension current-file) |
| 631 | ada-project-file-extension)) | 642 | ada-prj-file-extension)) |
| 632 | (dir (file-name-directory current-file)) | 643 | (dir (file-name-directory current-file)) |
| 633 | 644 | ||
| 634 | ;; on Emacs 20.2, directory-files does not work if | 645 | ;; on Emacs 20.2, directory-files does not work if |
| @@ -637,7 +648,7 @@ file. If none is set, return nil." | |||
| 637 | (prj-files (directory-files | 648 | (prj-files (directory-files |
| 638 | dir t | 649 | dir t |
| 639 | (concat ".*" (regexp-quote | 650 | (concat ".*" (regexp-quote |
| 640 | ada-project-file-extension) "$"))) | 651 | ada-prj-file-extension) "$"))) |
| 641 | (choice nil)) | 652 | (choice nil)) |
| 642 | 653 | ||
| 643 | (cond | 654 | (cond |
| @@ -775,10 +786,10 @@ file. If none is set, return nil." | |||
| 775 | (reverse check_cmd)))) | 786 | (reverse check_cmd)))) |
| 776 | (if run_cmd (set 'project (plist-put project 'run_cmd | 787 | (if run_cmd (set 'project (plist-put project 'run_cmd |
| 777 | (reverse run_cmd)))) | 788 | (reverse run_cmd)))) |
| 778 | (set 'project (plist-put project 'debug_post_cmd | 789 | (if debug_post_cmd (set 'project (plist-put project 'debug_post_cmd |
| 779 | (reverse debug_post_cmd))) | 790 | (reverse debug_post_cmd)))) |
| 780 | (set 'project (plist-put project 'debug_pre_cmd | 791 | (if debug_pre_cmd (set 'project (plist-put project 'debug_pre_cmd |
| 781 | (reverse debug_pre_cmd))) | 792 | (reverse debug_pre_cmd)))) |
| 782 | 793 | ||
| 783 | ;; Kill the project buffer | 794 | ;; Kill the project buffer |
| 784 | (kill-buffer nil) | 795 | (kill-buffer nil) |
| @@ -1017,8 +1028,13 @@ If OTHER-FRAME is non-nil, display the cross-reference in another frame." | |||
| 1017 | ;; that file was too old or even did not exist, try to look in the whole | 1028 | ;; that file was too old or even did not exist, try to look in the whole |
| 1018 | ;; object path for a possible location. | 1029 | ;; object path for a possible location. |
| 1019 | (let ((identlist (ada-read-identifier pos))) | 1030 | (let ((identlist (ada-read-identifier pos))) |
| 1020 | (condition-case nil | 1031 | (condition-case err |
| 1021 | (ada-find-in-ali identlist other-frame) | 1032 | (ada-find-in-ali identlist other-frame) |
| 1033 | ;; File not found: print explicit error message | ||
| 1034 | (error-file-not-found | ||
| 1035 | (message (concat (error-message-string err) | ||
| 1036 | (nthcdr 1 err)))) | ||
| 1037 | |||
| 1022 | (error | 1038 | (error |
| 1023 | (let ((ali-file (ada-get-ali-file-name (ada-file-of identlist)))) | 1039 | (let ((ali-file (ada-get-ali-file-name (ada-file-of identlist)))) |
| 1024 | 1040 | ||
| @@ -1507,10 +1523,7 @@ file for possible paths." | |||
| 1507 | (let ((filename (ada-find-src-file-in-dir file))) | 1523 | (let ((filename (ada-find-src-file-in-dir file))) |
| 1508 | (if filename | 1524 | (if filename |
| 1509 | (expand-file-name filename) | 1525 | (expand-file-name filename) |
| 1510 | (error (concat | 1526 | (signal 'error-file-not-found (file-name-nondirectory file))) |
| 1511 | (file-name-nondirectory file) | ||
| 1512 | " not found in src_dir; please check your project file"))) | ||
| 1513 | |||
| 1514 | ))) | 1527 | ))) |
| 1515 | 1528 | ||
| 1516 | (defun ada-find-file-number-in-ali (file) | 1529 | (defun ada-find-file-number-in-ali (file) |
| @@ -1603,7 +1616,7 @@ Information is extracted from the ali file." | |||
| 1603 | (concat "^" (ada-line-of identlist) | 1616 | (concat "^" (ada-line-of identlist) |
| 1604 | "." (ada-column-of identlist) | 1617 | "." (ada-column-of identlist) |
| 1605 | "[ *]" (ada-name-of identlist) | 1618 | "[ *]" (ada-name-of identlist) |
| 1606 | "[{\(<= ]?\\(.*\\)$") bound t)) | 1619 | "[{\[\(<= ]?\\(.*\\)$") bound t)) |
| 1607 | (if declaration-found | 1620 | (if declaration-found |
| 1608 | (ada-set-on-declaration identlist t)) | 1621 | (ada-set-on-declaration identlist t)) |
| 1609 | )) | 1622 | )) |
| @@ -1635,7 +1648,7 @@ Information is extracted from the ali file." | |||
| 1635 | (concat | 1648 | (concat |
| 1636 | "^[0-9]+.[0-9]+[ *]" | 1649 | "^[0-9]+.[0-9]+[ *]" |
| 1637 | (ada-name-of identlist) | 1650 | (ada-name-of identlist) |
| 1638 | "[ <{=\(]\\(.\\|\n\\.\\)*\\<" | 1651 | "[ <{=\(\[]\\(.\\|\n\\.\\)*\\<" |
| 1639 | (ada-line-of identlist) | 1652 | (ada-line-of identlist) |
| 1640 | "[^0-9]" | 1653 | "[^0-9]" |
| 1641 | (ada-column-of identlist) "\\>") | 1654 | (ada-column-of identlist) "\\>") |
| @@ -1655,9 +1668,10 @@ Information is extracted from the ali file." | |||
| 1655 | (beginning-of-line) | 1668 | (beginning-of-line) |
| 1656 | ;; while we have a continuation line, go up one line | 1669 | ;; while we have a continuation line, go up one line |
| 1657 | (while (looking-at "^\\.") | 1670 | (while (looking-at "^\\.") |
| 1658 | (previous-line 1)) | 1671 | (previous-line 1) |
| 1672 | (beginning-of-line)) | ||
| 1659 | (unless (looking-at (concat "[0-9]+.[0-9]+[ *]" | 1673 | (unless (looking-at (concat "[0-9]+.[0-9]+[ *]" |
| 1660 | (ada-name-of identlist) "[ <{=\(]")) | 1674 | (ada-name-of identlist) "[ <{=\(\[]")) |
| 1661 | (set 'declaration-found nil)))) | 1675 | (set 'declaration-found nil)))) |
| 1662 | 1676 | ||
| 1663 | ;; Still no success ! The ali file must be too old, and we need to | 1677 | ;; Still no success ! The ali file must be too old, and we need to |
| @@ -1700,6 +1714,8 @@ Information is extracted from the ali file." | |||
| 1700 | (ada-file-of identlist))) | 1714 | (ada-file-of identlist))) |
| 1701 | 1715 | ||
| 1702 | ;; Else clean up the ali file | 1716 | ;; Else clean up the ali file |
| 1717 | (error-file-not-found | ||
| 1718 | (signal (car err) (cdr err))) | ||
| 1703 | (error | 1719 | (error |
| 1704 | (kill-buffer ali-buffer) | 1720 | (kill-buffer ali-buffer) |
| 1705 | (error (error-message-string err))) | 1721 | (error (error-message-string err))) |
| @@ -1817,7 +1833,7 @@ opens a new window to show the declaration." | |||
| 1817 | ;; In that case, we simply go to each one in turn. | 1833 | ;; In that case, we simply go to each one in turn. |
| 1818 | 1834 | ||
| 1819 | ;; Get all the possible locations | 1835 | ;; Get all the possible locations |
| 1820 | (string-match "^\\([0-9]+\\)[a-zA-Z+]\\([0-9]+\\)[ *]" ali-line) | 1836 | (string-match "^\\([0-9]+\\)[a-zA-Z+*]\\([0-9]+\\)[ *]" ali-line) |
| 1821 | (set 'locations (list (list (match-string 1 ali-line) ;; line | 1837 | (set 'locations (list (list (match-string 1 ali-line) ;; line |
| 1822 | (match-string 2 ali-line) ;; column | 1838 | (match-string 2 ali-line) ;; column |
| 1823 | (ada-declare-file-of identlist)))) | 1839 | (ada-declare-file-of identlist)))) |
| @@ -1828,7 +1844,10 @@ opens a new window to show the declaration." | |||
| 1828 | start (match-end 3)) | 1844 | start (match-end 3)) |
| 1829 | 1845 | ||
| 1830 | ;; it there was a file number in the same line | 1846 | ;; it there was a file number in the same line |
| 1831 | (if (string-match (concat "[^{(<]\\([0-9]+\\)|\\([^|bc]+\\)?" | 1847 | ;; Make sure we correctly handle the case where the first file reference |
| 1848 | ;; on the line is the type reference. | ||
| 1849 | ;; 1U2 T(2|2r3) 34r23 | ||
| 1850 | (if (string-match (concat "[^{(<0-9]\\([0-9]+\\)|\\([^|bc]+\\)?" | ||
| 1832 | (match-string 0 ali-line)) | 1851 | (match-string 0 ali-line)) |
| 1833 | ali-line) | 1852 | ali-line) |
| 1834 | (let ((file-number (match-string 1 ali-line))) | 1853 | (let ((file-number (match-string 1 ali-line))) |
| @@ -1997,7 +2016,7 @@ is using." | |||
| 1997 | (string-to-number (nth 2 (nth choice list))) | 2016 | (string-to-number (nth 2 (nth choice list))) |
| 1998 | identlist | 2017 | identlist |
| 1999 | other-frame) | 2018 | other-frame) |
| 2000 | (error (concat (car (nth choice list)) " not found in src_dir"))) | 2019 | (signal 'error-file-not-found (car (nth choice list)))) |
| 2001 | (message "This is only a (good) guess at the cross-reference.") | 2020 | (message "This is only a (good) guess at the cross-reference.") |
| 2002 | )))) | 2021 | )))) |
| 2003 | 2022 | ||
| @@ -2137,8 +2156,12 @@ This is a GNAT specific function that uses gnatkrunch." | |||
| 2137 | (save-excursion | 2156 | (save-excursion |
| 2138 | (set-buffer krunch-buf) | 2157 | (set-buffer krunch-buf) |
| 2139 | ;; send adaname to external process `gnatkr'. | 2158 | ;; send adaname to external process `gnatkr'. |
| 2159 | ;; Add a dummy extension, since gnatkr versions have two different | ||
| 2160 | ;; behaviors depending on the version: | ||
| 2161 | ;; Up to 3.15: "AA.BB.CC" => aa-bb-cc | ||
| 2162 | ;; After: "AA.BB.CC" => aa-bb.cc | ||
| 2140 | (call-process "gnatkr" nil krunch-buf nil | 2163 | (call-process "gnatkr" nil krunch-buf nil |
| 2141 | adaname ada-krunch-args) | 2164 | (concat adaname ".adb") ada-krunch-args) |
| 2142 | ;; fetch output of that process | 2165 | ;; fetch output of that process |
| 2143 | (setq adaname (buffer-substring | 2166 | (setq adaname (buffer-substring |
| 2144 | (point-min) | 2167 | (point-min) |
| @@ -2146,6 +2169,9 @@ This is a GNAT specific function that uses gnatkrunch." | |||
| 2146 | (goto-char (point-min)) | 2169 | (goto-char (point-min)) |
| 2147 | (end-of-line) | 2170 | (end-of-line) |
| 2148 | (point)))) | 2171 | (point)))) |
| 2172 | ;; Remove the extra extension we added above | ||
| 2173 | (setq adaname (substring adaname 0 -4)) | ||
| 2174 | |||
| 2149 | (kill-buffer krunch-buf))) | 2175 | (kill-buffer krunch-buf))) |
| 2150 | adaname | 2176 | adaname |
| 2151 | ) | 2177 | ) |
| @@ -2234,6 +2260,14 @@ find-file...." | |||
| 2234 | ;; This must be done before initializing the Ada menu. | 2260 | ;; This must be done before initializing the Ada menu. |
| 2235 | (add-hook 'ada-mode-hook 'ada-xref-initialize) | 2261 | (add-hook 'ada-mode-hook 'ada-xref-initialize) |
| 2236 | 2262 | ||
| 2263 | ;; Define a new error type | ||
| 2264 | (put 'error-file-not-found | ||
| 2265 | 'error-conditions | ||
| 2266 | '(error ada-mode-errors error-file-not-found)) | ||
| 2267 | (put 'error-file-not-found | ||
| 2268 | 'error-message | ||
| 2269 | "File not found in src-dir (check project file): ") | ||
| 2270 | |||
| 2237 | ;; Initializes the cross references to the runtime library | 2271 | ;; Initializes the cross references to the runtime library |
| 2238 | (ada-initialize-runtime-library "") | 2272 | (ada-initialize-runtime-library "") |
| 2239 | 2273 | ||