diff options
| author | Juanma Barranquero | 2003-04-29 23:43:00 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-04-29 23:43:00 +0000 |
| commit | ce20e709a2944863cf4e25ac8a667ec49bcce108 (patch) | |
| tree | 5e935542291013e23082e1c20e60f1dc63fcf9a8 | |
| parent | c94ca9e0b3eb7b95197c14f26357a8bca1da0a83 (diff) | |
| download | emacs-ce20e709a2944863cf4e25ac8a667ec49bcce108.tar.gz emacs-ce20e709a2944863cf4e25ac8a667ec49bcce108.zip | |
(ada-prj-add-keymap): Moved to ada-mode.el directly. Add dependency on
ada-xref.el to avoid compilation warnings.
(ada-prj-get-prj-dir): Removed, no longer needed.
| -rw-r--r-- | lisp/progmodes/ada-prj.el | 84 |
1 files changed, 28 insertions, 56 deletions
diff --git a/lisp/progmodes/ada-prj.el b/lisp/progmodes/ada-prj.el index ce96f43f4ed..40bd382a34d 100644 --- a/lisp/progmodes/ada-prj.el +++ b/lisp/progmodes/ada-prj.el | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | ;;; ada-prj.el --- easy editing of project files for the ada-mode | 1 | ;;; ada-prj.el --- easy editing of project files for the ada-mode |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1998, 99, 2000, 2001, 2002 | 3 | ;; Copyright (C) 1998, 99, 2000-2003 Free Software Foundation, Inc. |
| 4 | ;; Free Software Foundation, Inc. | ||
| 5 | 4 | ||
| 6 | ;; Author: Emmanuel Briot <briot@gnat.com> | 5 | ;; Author: Emmanuel Briot <briot@gnat.com> |
| 7 | ;; Ada Core Technologies's version: Revision: 1.55.2.2 (GNAT 3.15) | 6 | ;; Ada Core Technologies's version: $Revision: 1.60 $ |
| 8 | ;; Keywords: languages, ada, project file | 7 | ;; Keywords: languages, ada, project file |
| 9 | 8 | ||
| 10 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| @@ -39,16 +38,19 @@ | |||
| 39 | 38 | ||
| 40 | ;; ----- Requirements ----------------------------------------------------- | 39 | ;; ----- Requirements ----------------------------------------------------- |
| 41 | 40 | ||
| 41 | (eval-when-compile | ||
| 42 | (require 'ada-mode)) | ||
| 42 | (require 'cus-edit) | 43 | (require 'cus-edit) |
| 44 | (require 'ada-xref) | ||
| 43 | 45 | ||
| 44 | ;; ----- Buffer local variables ------------------------------------------- | 46 | ;; ----- Buffer local variables ------------------------------------------- |
| 45 | 47 | ||
| 46 | (defvar ada-prj-current-values nil | 48 | (defvar ada-prj-current-values nil |
| 47 | "Hold the current value of the fields, This is a property list.") | 49 | "Hold the current value of the fields; this is a property list.") |
| 48 | (make-variable-buffer-local 'ada-prj-current-values) | 50 | (make-variable-buffer-local 'ada-prj-current-values) |
| 49 | 51 | ||
| 50 | (defvar ada-prj-default-values nil | 52 | (defvar ada-prj-default-values nil |
| 51 | "Hold the default value for the fields, This is a property list.") | 53 | "Hold the default value for the fields; this is a property list.") |
| 52 | (make-variable-buffer-local 'ada-prj-default-values) | 54 | (make-variable-buffer-local 'ada-prj-default-values) |
| 53 | 55 | ||
| 54 | (defvar ada-prj-ada-buffer nil | 56 | (defvar ada-prj-ada-buffer nil |
| @@ -86,37 +88,22 @@ If there is none, opens a new project file" | |||
| 86 | (ada-customize) | 88 | (ada-customize) |
| 87 | (ada-prj-new))) | 89 | (ada-prj-new))) |
| 88 | 90 | ||
| 89 | (defun ada-prj-add-keymap () | 91 | (defun ada-prj-initialize-values (symbol ada-buffer filename) |
| 90 | "Add new keybindings for ada-prj." | ||
| 91 | (define-key ada-mode-map "\C-cu" 'ada-prj-edit)) | ||
| 92 | |||
| 93 | (defun ada-prj-initialize-values (symbol ada-buffer &optional filename) | ||
| 94 | "Set SYMBOL to the property list of the project file FILENAME. | 92 | "Set SYMBOL to the property list of the project file FILENAME. |
| 95 | If FILENAME is null, read the file associated with ADA-BUFFER. If no | 93 | If FILENAME is null, read the file associated with ADA-BUFFER. If no |
| 96 | project file is found, returns the default values." | 94 | project file is found, returns the default values." |
| 97 | 95 | ||
| 98 | (let ((prj filename)) | 96 | (if (and filename |
| 99 | 97 | (not (string= filename "")) | |
| 100 | (if filename | 98 | (assoc filename ada-xref-project-files)) |
| 101 | ;; If filename is given, reread if first if needed | 99 | (set symbol (copy-sequence (cdr (assoc filename ada-xref-project-files)))) |
| 102 | (if (file-exists-p filename) | ||
| 103 | (ada-reread-prj-file)) | ||
| 104 | |||
| 105 | ;; Else use the active one | ||
| 106 | (set 'prj ada-prj-default-project-file)) | ||
| 107 | |||
| 108 | 100 | ||
| 109 | (if (and prj | 101 | ;; Set default values (except for the file name if this was given |
| 110 | (not (string= prj "")) | 102 | ;; in the buffer |
| 111 | (assoc prj ada-xref-project-files)) | 103 | (ada-xref-set-default-prj-values symbol ada-buffer) |
| 112 | (set symbol (copy-sequence (cdr (assoc prj ada-xref-project-files)))) | 104 | (if (and filename (not (string= filename ""))) |
| 113 | 105 | (set symbol (plist-put (eval symbol) 'filename filename))) | |
| 114 | ;; Set default values (except for the file name if this was given | 106 | )) |
| 115 | ;; in the buffer | ||
| 116 | (ada-xref-set-default-prj-values symbol ada-buffer) | ||
| 117 | (if (and prj (not (string= prj ""))) | ||
| 118 | (set symbol (plist-put (eval symbol) 'filename prj))) | ||
| 119 | ))) | ||
| 120 | 107 | ||
| 121 | 108 | ||
| 122 | (defun ada-prj-save-specific-option (field) | 109 | (defun ada-prj-save-specific-option (field) |
| @@ -258,7 +245,7 @@ The current buffer must be the project editing buffer." | |||
| 258 | (erase-buffer)) | 245 | (erase-buffer)) |
| 259 | 246 | ||
| 260 | ;; Widget support in Emacs 21 requires that we clear the buffer first | 247 | ;; Widget support in Emacs 21 requires that we clear the buffer first |
| 261 | (if (and (not (boundp 'running-xemacs)) (>= emacs-major-version 21)) | 248 | (if (and (not ada-xemacs) (>= emacs-major-version 21)) |
| 262 | (progn | 249 | (progn |
| 263 | (setq widget-field-new nil | 250 | (setq widget-field-new nil |
| 264 | widget-field-list nil) | 251 | widget-field-list nil) |
| @@ -516,13 +503,19 @@ If FILENAME is given, edit that file." | |||
| 516 | (add-hook 'after-save-hook 'ada-reread-prj-file t t) | 503 | (add-hook 'after-save-hook 'ada-reread-prj-file t t) |
| 517 | ) | 504 | ) |
| 518 | 505 | ||
| 506 | (if filename | ||
| 507 | (ada-reread-prj-file filename) | ||
| 508 | (if (not (string= ada-prj-default-project-file "")) | ||
| 509 | (ada-reread-prj-file ada-prj-default-project-file) | ||
| 510 | (ada-reread-prj-file))) | ||
| 511 | |||
| 519 | ;; Else start the interactive editor | 512 | ;; Else start the interactive editor |
| 520 | (switch-to-buffer "*Customize Ada Mode*") | 513 | (switch-to-buffer "*Customize Ada Mode*") |
| 521 | (kill-all-local-variables) | ||
| 522 | 514 | ||
| 523 | (ada-xref-set-default-prj-values 'ada-prj-default-values ada-buffer) | 515 | (ada-xref-set-default-prj-values 'ada-prj-default-values ada-buffer) |
| 524 | (ada-prj-initialize-values | 516 | (ada-prj-initialize-values 'ada-prj-current-values |
| 525 | 'ada-prj-current-values ada-buffer filename) | 517 | ada-buffer |
| 518 | ada-prj-default-project-file) | ||
| 526 | 519 | ||
| 527 | (set (make-local-variable 'ada-prj-ada-buffer) ada-buffer) | 520 | (set (make-local-variable 'ada-prj-ada-buffer) ada-buffer) |
| 528 | 521 | ||
| @@ -553,23 +546,6 @@ directory name." | |||
| 553 | ada-list "\n")) | 546 | ada-list "\n")) |
| 554 | 547 | ||
| 555 | 548 | ||
| 556 | (defun ada-prj-get-prj-dir (&optional ada-file) | ||
| 557 | "Returns the directory/name of the project file for ADA-FILE. | ||
| 558 | If ADA-FILE is nil, returns the project file for the current buffer." | ||
| 559 | (unless ada-file | ||
| 560 | (setq ada-file (buffer-file-name))) | ||
| 561 | |||
| 562 | (save-excursion | ||
| 563 | (let ((prj-file (ada-prj-find-prj-file t))) | ||
| 564 | (if (or (not prj-file) | ||
| 565 | (not (file-exists-p prj-file)) | ||
| 566 | ) | ||
| 567 | (setq prj-file | ||
| 568 | (concat (file-name-sans-extension ada-file) | ||
| 569 | ada-project-file-extension))) | ||
| 570 | prj-file) | ||
| 571 | )) | ||
| 572 | |||
| 573 | (defun ada-prj-field-modified (widget &rest dummy) | 549 | (defun ada-prj-field-modified (widget &rest dummy) |
| 574 | "Callback called each time the value of WIDGET is modified. Save the | 550 | "Callback called each time the value of WIDGET is modified. Save the |
| 575 | change in ada-prj-current-values so that selecting another page and coming | 551 | change in ada-prj-current-values so that selecting another page and coming |
| @@ -702,10 +678,6 @@ AFTER-TEXT is inserted just after the widget." | |||
| 702 | )) | 678 | )) |
| 703 | 679 | ||
| 704 | 680 | ||
| 705 | ;; Set the keymap once and for all, so that the keys set by the user in his | ||
| 706 | ;; config file are not overwritten every time we open a new file. | ||
| 707 | (ada-prj-add-keymap) | ||
| 708 | |||
| 709 | (provide 'ada-prj) | 681 | (provide 'ada-prj) |
| 710 | 682 | ||
| 711 | ;;; ada-prj.el ends here | 683 | ;;; ada-prj.el ends here |