From ce20e709a2944863cf4e25ac8a667ec49bcce108 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Tue, 29 Apr 2003 23:43:00 +0000 Subject: (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. --- lisp/progmodes/ada-prj.el | 84 ++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 56 deletions(-) (limited to 'lisp/progmodes/ada-prj.el') diff --git a/lisp/progmodes/ada-prj.el b/lisp/progmodes/ada-prj.el index ce96f43f4e..40bd382a34 100644 --- a/lisp/progmodes/ada-prj.el +++ b/lisp/progmodes/ada-prj.el @@ -1,10 +1,9 @@ ;;; ada-prj.el --- easy editing of project files for the ada-mode -;; Copyright (C) 1998, 99, 2000, 2001, 2002 -;; Free Software Foundation, Inc. +;; Copyright (C) 1998, 99, 2000-2003 Free Software Foundation, Inc. ;; Author: Emmanuel Briot -;; Ada Core Technologies's version: Revision: 1.55.2.2 (GNAT 3.15) +;; Ada Core Technologies's version: $Revision: 1.60 $ ;; Keywords: languages, ada, project file ;; This file is part of GNU Emacs. @@ -39,16 +38,19 @@ ;; ----- Requirements ----------------------------------------------------- +(eval-when-compile + (require 'ada-mode)) (require 'cus-edit) +(require 'ada-xref) ;; ----- Buffer local variables ------------------------------------------- (defvar ada-prj-current-values nil - "Hold the current value of the fields, This is a property list.") + "Hold the current value of the fields; this is a property list.") (make-variable-buffer-local 'ada-prj-current-values) (defvar ada-prj-default-values nil - "Hold the default value for the fields, This is a property list.") + "Hold the default value for the fields; this is a property list.") (make-variable-buffer-local 'ada-prj-default-values) (defvar ada-prj-ada-buffer nil @@ -86,37 +88,22 @@ If there is none, opens a new project file" (ada-customize) (ada-prj-new))) -(defun ada-prj-add-keymap () - "Add new keybindings for ada-prj." - (define-key ada-mode-map "\C-cu" 'ada-prj-edit)) - -(defun ada-prj-initialize-values (symbol ada-buffer &optional filename) +(defun ada-prj-initialize-values (symbol ada-buffer filename) "Set SYMBOL to the property list of the project file FILENAME. If FILENAME is null, read the file associated with ADA-BUFFER. If no project file is found, returns the default values." - (let ((prj filename)) - - (if filename - ;; If filename is given, reread if first if needed - (if (file-exists-p filename) - (ada-reread-prj-file)) - - ;; Else use the active one - (set 'prj ada-prj-default-project-file)) - + (if (and filename + (not (string= filename "")) + (assoc filename ada-xref-project-files)) + (set symbol (copy-sequence (cdr (assoc filename ada-xref-project-files)))) - (if (and prj - (not (string= prj "")) - (assoc prj ada-xref-project-files)) - (set symbol (copy-sequence (cdr (assoc prj ada-xref-project-files)))) - - ;; Set default values (except for the file name if this was given - ;; in the buffer - (ada-xref-set-default-prj-values symbol ada-buffer) - (if (and prj (not (string= prj ""))) - (set symbol (plist-put (eval symbol) 'filename prj))) - ))) + ;; Set default values (except for the file name if this was given + ;; in the buffer + (ada-xref-set-default-prj-values symbol ada-buffer) + (if (and filename (not (string= filename ""))) + (set symbol (plist-put (eval symbol) 'filename filename))) + )) (defun ada-prj-save-specific-option (field) @@ -258,7 +245,7 @@ The current buffer must be the project editing buffer." (erase-buffer)) ;; Widget support in Emacs 21 requires that we clear the buffer first - (if (and (not (boundp 'running-xemacs)) (>= emacs-major-version 21)) + (if (and (not ada-xemacs) (>= emacs-major-version 21)) (progn (setq widget-field-new nil widget-field-list nil) @@ -516,13 +503,19 @@ If FILENAME is given, edit that file." (add-hook 'after-save-hook 'ada-reread-prj-file t t) ) + (if filename + (ada-reread-prj-file filename) + (if (not (string= ada-prj-default-project-file "")) + (ada-reread-prj-file ada-prj-default-project-file) + (ada-reread-prj-file))) + ;; Else start the interactive editor (switch-to-buffer "*Customize Ada Mode*") - (kill-all-local-variables) (ada-xref-set-default-prj-values 'ada-prj-default-values ada-buffer) - (ada-prj-initialize-values - 'ada-prj-current-values ada-buffer filename) + (ada-prj-initialize-values 'ada-prj-current-values + ada-buffer + ada-prj-default-project-file) (set (make-local-variable 'ada-prj-ada-buffer) ada-buffer) @@ -553,23 +546,6 @@ directory name." ada-list "\n")) -(defun ada-prj-get-prj-dir (&optional ada-file) - "Returns the directory/name of the project file for ADA-FILE. -If ADA-FILE is nil, returns the project file for the current buffer." - (unless ada-file - (setq ada-file (buffer-file-name))) - - (save-excursion - (let ((prj-file (ada-prj-find-prj-file t))) - (if (or (not prj-file) - (not (file-exists-p prj-file)) - ) - (setq prj-file - (concat (file-name-sans-extension ada-file) - ada-project-file-extension))) - prj-file) - )) - (defun ada-prj-field-modified (widget &rest dummy) "Callback called each time the value of WIDGET is modified. Save the 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." )) -;; Set the keymap once and for all, so that the keys set by the user in his -;; config file are not overwritten every time we open a new file. -(ada-prj-add-keymap) - (provide 'ada-prj) ;;; ada-prj.el ends here -- cgit v1.2.3