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 Free Software Foundation, Inc. |
;; Copyright (C) 1998, 99, 2000, 2001, 2002 |
4 |
|
;; Free Software Foundation, Inc. |
5 |
|
|
6 |
;; Author: Emmanuel Briot <briot@gnat.com> |
;; Author: Emmanuel Briot <briot@gnat.com> |
7 |
;; Ada Core Technologies's version: $Revision$ |
;; Ada Core Technologies's version: Revision: 1.55.2.2 (GNAT 3.15) |
8 |
;; Keywords: languages, ada, project file |
;; Keywords: languages, ada, project file |
9 |
|
|
10 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
82 |
"Editing the project file associated with the current Ada buffer. |
"Editing the project file associated with the current Ada buffer. |
83 |
If there is none, opens a new project file" |
If there is none, opens a new project file" |
84 |
(interactive) |
(interactive) |
85 |
(let ((file (ada-prj-find-prj-file))) |
(if ada-prj-default-project-file |
86 |
(if file |
(ada-customize) |
87 |
(progn |
(ada-prj-new))) |
|
(ada-reread-prj-file file) |
|
|
(ada-customize)) |
|
|
(ada-prj-new)))) |
|
88 |
|
|
89 |
(defun ada-prj-add-keymap () |
(defun ada-prj-add-keymap () |
90 |
"Add new keybindings for ada-prj." |
"Add new keybindings for ada-prj." |
234 |
(defun ada-prj-load-directory (field &optional file-name) |
(defun ada-prj-load-directory (field &optional file-name) |
235 |
"Append the content of FILE-NAME to FIELD in the current project file. |
"Append the content of FILE-NAME to FIELD in the current project file. |
236 |
If FILE-NAME is nil, ask the user for the name." |
If FILE-NAME is nil, ask the user for the name." |
237 |
(unless file-name |
|
238 |
(set 'file-name (read-file-name "Root directory: " nil nil t))) |
;; Do not use an external dialog for this, since it wouldn't allow |
239 |
|
;; the user to select a directory |
240 |
|
(let ((use-dialog-box nil)) |
241 |
|
(unless file-name |
242 |
|
(set 'file-name (read-file-name "Root directory: " nil nil t)))) |
243 |
|
|
244 |
(set 'ada-prj-current-values |
(set 'ada-prj-current-values |
245 |
(plist-put ada-prj-current-values |
(plist-put ada-prj-current-values |
502 |
(let ((ada-buffer (current-buffer)) |
(let ((ada-buffer (current-buffer)) |
503 |
(inhibit-read-only t)) |
(inhibit-read-only t)) |
504 |
|
|
505 |
(ada-require-project-file) |
;; We can only edit interactively the standard ada-mode project files. If |
506 |
|
;; the user is using other formats for the project file (through hooks in |
507 |
(switch-to-buffer "*Customize Ada Mode*") |
;; `ada-load-project-hook', we simply edit the file |
|
(kill-all-local-variables) |
|
508 |
|
|
509 |
(ada-xref-set-default-prj-values 'ada-prj-default-values ada-buffer) |
(if (and (not new-file) |
510 |
(ada-prj-initialize-values 'ada-prj-current-values ada-buffer filename) |
(or ada-prj-default-project-file filename) |
511 |
|
(string= (file-name-extension |
512 |
(set (make-local-variable 'ada-prj-ada-buffer) ada-buffer) |
(or filename ada-prj-default-project-file)) |
513 |
|
"gpr")) |
514 |
(use-local-map (copy-keymap custom-mode-map)) |
(progn |
515 |
(local-set-key "\C-x\C-s" 'ada-prj-save) |
(find-file ada-prj-default-project-file) |
516 |
|
(add-hook 'after-save-hook 'ada-reread-prj-file t t) |
517 |
(make-local-variable 'widget-keymap) |
) |
518 |
(define-key widget-keymap "\C-x\C-s" 'ada-prj-save) |
|
519 |
|
;; Else start the interactive editor |
520 |
(set (make-local-variable 'ada-old-cross-prefix) |
(switch-to-buffer "*Customize Ada Mode*") |
521 |
(ada-xref-get-project-field 'cross-prefix)) |
(kill-all-local-variables) |
522 |
|
|
523 |
(ada-prj-display-page 1) |
(ada-xref-set-default-prj-values 'ada-prj-default-values ada-buffer) |
524 |
)) |
(ada-prj-initialize-values |
525 |
|
'ada-prj-current-values ada-buffer filename) |
526 |
|
|
527 |
|
(set (make-local-variable 'ada-prj-ada-buffer) ada-buffer) |
528 |
|
|
529 |
|
(use-local-map (copy-keymap custom-mode-map)) |
530 |
|
(local-set-key "\C-x\C-s" 'ada-prj-save) |
531 |
|
|
532 |
|
(make-local-variable 'widget-keymap) |
533 |
|
(define-key widget-keymap "\C-x\C-s" 'ada-prj-save) |
534 |
|
|
535 |
|
(set (make-local-variable 'ada-old-cross-prefix) |
536 |
|
(ada-xref-get-project-field 'cross-prefix)) |
537 |
|
|
538 |
|
(ada-prj-display-page 1) |
539 |
|
))) |
540 |
|
|
541 |
;; ---------------- Utilities -------------------------------- |
;; ---------------- Utilities -------------------------------- |
542 |
|
|
560 |
(setq ada-file (buffer-file-name))) |
(setq ada-file (buffer-file-name))) |
561 |
|
|
562 |
(save-excursion |
(save-excursion |
|
(set-buffer (get-file-buffer ada-file)) |
|
|
|
|
563 |
(let ((prj-file (ada-prj-find-prj-file t))) |
(let ((prj-file (ada-prj-find-prj-file t))) |
564 |
(if (or (not prj-file) |
(if (or (not prj-file) |
565 |
(not (file-exists-p prj-file)) |
(not (file-exists-p prj-file)) |