1 |
;;; ada-prj.el --- easy editing of project files for the ada-mode |
;;; ada-prj.el --- easy editing of project files for the ada-mode |
2 |
|
|
3 |
;; Copyright (C) 1998, 99, 2000, 2001, 2002 |
;; Copyright (C) 1998, 99, 2000-2003 Free Software Foundation, Inc. |
|
;; Free Software Foundation, Inc. |
|
4 |
|
|
5 |
;; Author: Emmanuel Briot <briot@gnat.com> |
;; Author: Emmanuel Briot <briot@gnat.com> |
6 |
;; Ada Core Technologies's version: Revision: 1.55.2.2 (GNAT 3.15) |
;; Ada Core Technologies's version: $Revision$ |
7 |
;; Keywords: languages, ada, project file |
;; Keywords: languages, ada, project file |
8 |
|
|
9 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
39 |
;; ----- Requirements ----------------------------------------------------- |
;; ----- Requirements ----------------------------------------------------- |
40 |
|
|
41 |
(require 'cus-edit) |
(require 'cus-edit) |
42 |
|
(require 'ada-xref) |
43 |
|
|
44 |
|
(eval-when-compile |
45 |
|
(require 'ada-mode)) |
46 |
|
|
47 |
;; ----- Buffer local variables ------------------------------------------- |
;; ----- Buffer local variables ------------------------------------------- |
48 |
|
|
89 |
(ada-customize) |
(ada-customize) |
90 |
(ada-prj-new))) |
(ada-prj-new))) |
91 |
|
|
92 |
(defun ada-prj-add-keymap () |
(defun ada-prj-initialize-values (symbol ada-buffer filename) |
|
"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) |
|
93 |
"Set SYMBOL to the property list of the project file FILENAME. |
"Set SYMBOL to the property list of the project file FILENAME. |
94 |
If FILENAME is null, read the file associated with ADA-BUFFER. If no |
If FILENAME is null, read the file associated with ADA-BUFFER. If no |
95 |
project file is found, returns the default values." |
project file is found, returns the default values." |
96 |
|
|
97 |
(let ((prj filename)) |
(if (and filename |
98 |
|
(not (string= filename "")) |
99 |
(if filename |
(assoc filename ada-xref-project-files)) |
100 |
;; If filename is given, reread if first if needed |
(set symbol (copy-sequence (cdr (assoc filename ada-xref-project-files)))) |
101 |
(if (file-exists-p filename) |
|
102 |
(ada-reread-prj-file)) |
;; Set default values (except for the file name if this was given |
103 |
|
;; in the buffer |
104 |
;; Else use the active one |
(ada-xref-set-default-prj-values symbol ada-buffer) |
105 |
(set 'prj ada-prj-default-project-file)) |
(if (and filename (not (string= filename ""))) |
106 |
|
(set symbol (plist-put (eval symbol) 'filename filename))) |
107 |
|
)) |
|
(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))) |
|
|
))) |
|
108 |
|
|
109 |
|
|
110 |
(defun ada-prj-save-specific-option (field) |
(defun ada-prj-save-specific-option (field) |
246 |
(erase-buffer)) |
(erase-buffer)) |
247 |
|
|
248 |
;; Widget support in Emacs 21 requires that we clear the buffer first |
;; Widget support in Emacs 21 requires that we clear the buffer first |
249 |
(if (and (not (boundp 'running-xemacs)) (>= emacs-major-version 21)) |
(if (and (not (featurep 'xemacs)) (>= emacs-major-version 21)) |
250 |
(progn |
(progn |
251 |
(setq widget-field-new nil |
(setq widget-field-new nil |
252 |
widget-field-list nil) |
widget-field-list nil) |
504 |
(add-hook 'after-save-hook 'ada-reread-prj-file t t) |
(add-hook 'after-save-hook 'ada-reread-prj-file t t) |
505 |
) |
) |
506 |
|
|
507 |
|
(if filename |
508 |
|
(ada-reread-prj-file filename) |
509 |
|
(if (not (string= ada-prj-default-project-file "")) |
510 |
|
(ada-reread-prj-file ada-prj-default-project-file) |
511 |
|
(ada-reread-prj-file))) |
512 |
|
|
513 |
;; Else start the interactive editor |
;; Else start the interactive editor |
514 |
(switch-to-buffer "*Customize Ada Mode*") |
(switch-to-buffer "*Customize Ada Mode*") |
|
(kill-all-local-variables) |
|
515 |
|
|
516 |
(ada-xref-set-default-prj-values 'ada-prj-default-values ada-buffer) |
(ada-xref-set-default-prj-values 'ada-prj-default-values ada-buffer) |
517 |
(ada-prj-initialize-values |
(ada-prj-initialize-values 'ada-prj-current-values |
518 |
'ada-prj-current-values ada-buffer filename) |
ada-buffer |
519 |
|
ada-prj-default-project-file) |
520 |
|
|
521 |
(set (make-local-variable 'ada-prj-ada-buffer) ada-buffer) |
(set (make-local-variable 'ada-prj-ada-buffer) ada-buffer) |
522 |
|
|
547 |
ada-list "\n")) |
ada-list "\n")) |
548 |
|
|
549 |
|
|
|
(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) |
|
|
)) |
|
|
|
|
550 |
(defun ada-prj-field-modified (widget &rest dummy) |
(defun ada-prj-field-modified (widget &rest dummy) |
551 |
"Callback called each time the value of WIDGET is modified. Save the |
"Callback called each time the value of WIDGET is modified. Save the |
552 |
change in ada-prj-current-values so that selecting another page and coming |
change in ada-prj-current-values so that selecting another page and coming |
679 |
)) |
)) |
680 |
|
|
681 |
|
|
|
;; 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) |
|
|
|
|
682 |
(provide 'ada-prj) |
(provide 'ada-prj) |
683 |
|
|
684 |
|
;;; arch-tag: 65978c77-816e-49c6-896e-6905605d1b4c |
685 |
;;; ada-prj.el ends here |
;;; ada-prj.el ends here |