-(defun ada-prj-customize ()
- "Edit the project file whose name is given by prj-file."
- (let* ((old-name (buffer-file-name))
- prj-file)
-
- (unless old-name
- (error
- "No file name given for this buffer ! You need to open a file first"))
-
- ;; Find the project file associated with the buffer
- (setq prj-file (ada-prj-get-prj-dir old-name))
-
- (switch-to-buffer "*Customize Ada Mode*")
- (kill-all-local-variables)
-
- ;; Find the default values
- (setq ada-prj-default nil)
- (put 'ada-prj-default 'src_dir (list (file-name-directory old-name)))
- (put 'ada-prj-default 'obj_dir (list (file-name-directory old-name)))
- (put 'ada-prj-default 'comp_opt "")
- (put 'ada-prj-default 'bind_opt "")
- (put 'ada-prj-default 'link_opt "")
- (put 'ada-prj-default 'main "")
- (put 'ada-prj-default 'cross_prefix "")
- (put 'ada-prj-default 'remote_machine "")
- (put 'ada-prj-default 'comp_cmd
- (concat "cd " (file-name-directory old-name) " && "
- ada-prj-default-comp-cmd))
- (put 'ada-prj-default 'make_cmd
- (concat "cd " (file-name-directory old-name) " && "
- ada-prj-default-make-cmd))
- (put 'ada-prj-default 'run_cmd (if is-windows "${main}.exe" "${main}"))
- (put 'ada-prj-default 'debug_cmd
- (if is-windows "${cross_prefix}gdb ${main}.exe"
- "${cross_prefix}gdb ${main}"))
-
- (let ((inhibit-read-only t))
- (erase-buffer))
-
- ;;; Overlay-lists is not defined on XEmacs
- (if (fboundp 'overlay-lists)
- (let ((all (overlay-lists)))
- ;; Delete all the overlays.
- (mapcar 'delete-overlay (car all))
- (mapcar 'delete-overlay (cdr all))))
-
- (use-local-map widget-keymap)
- (local-set-key "\C-x\C-s" 'ada-prj-save)
-
- (widget-insert "
-----------------------------------------------------------------
--- Customize your emacs ada mode for the current application --
-----------------------------------------------------------------
-This buffer will allow you to create easily a project file for your application.
-This file will tell emacs where to find the ada sources, the cross-referencing
-informations, how to compile and run your application, ...
-
-Please use the RETURN key, or middle mouse button to activate the fields.\n\n")
-
- ;; Reset Button
- (widget-create 'push-button
- :notify (lambda (&rest ignore)
- (setq ada-prj-edit-use-default-values t)
- (kill-buffer nil)
- (ada-prj-customize)
- (setq ada-prj-edit-use-default-values nil)
- )
- "Reset to Default Values")
- (widget-insert "\n")
+(defun ada-prj-load-from-file (symbol)
+ "Load SYMBOL value from file. One item per line should be found in the file."
+ (save-excursion
+ (let ((file (read-file-name "File name: " nil nil t))
+ (buffer (current-buffer))
+ line
+ list)
+ (find-file file)
+ (widen)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (set 'line (buffer-substring-no-properties
+ (point) (save-excursion (end-of-line) (point))))
+ (add-to-list 'list line)
+ (forward-line 1)
+ )
+ (kill-buffer nil)
+ (set-buffer buffer)
+ (set 'ada-prj-current-values
+ (plist-put ada-prj-current-values
+ symbol
+ (append (plist-get ada-prj-current-values symbol)
+ (reverse list))))
+ )
+ (ada-prj-display-page 2)
+ ))
+
+(defun ada-prj-subdirs-of (dir)
+ "Return a list of all the subdirectories of DIR, recursively."
+ (let ((subdirs (directory-files dir t "^[^.].*"))
+ (dirlist (list dir)))
+ (while subdirs
+ (if (file-directory-p (car subdirs))
+ (let ((sub (ada-prj-subdirs-of (car subdirs))))
+ (if sub
+ (set 'dirlist (append sub dirlist)))))
+ (set 'subdirs (cdr subdirs)))
+ dirlist))
+
+(defun ada-prj-load-directory (field &optional file-name)
+ "Append to FIELD in the current project the subdirectories of FILE-NAME.
+If FILE-NAME is nil, ask the user for the name."
+
+ ;; Do not use an external dialog for this, since it wouldn't allow
+ ;; the user to select a directory
+ (let ((use-dialog-box nil))
+ (unless file-name
+ (set 'file-name (read-file-name "Root directory: " nil nil t))))
+
+ (set 'ada-prj-current-values
+ (plist-put ada-prj-current-values
+ field
+ (append (plist-get ada-prj-current-values field)
+ (reverse (ada-prj-subdirs-of
+ (expand-file-name file-name))))))
+ (ada-prj-display-page 2))
+
+(defun ada-prj-display-page (tab-num)
+ "Display page TAB-NUM in the notebook.
+The current buffer must be the project editing buffer."
+
+ (let ((inhibit-read-only t))
+ (erase-buffer))
+
+ ;; Widget support in Emacs 21 requires that we clear the buffer first
+ (if (and (not (featurep 'xemacs)) (>= emacs-major-version 21))
+ (progn
+ (setq widget-field-new nil
+ widget-field-list nil)
+ (mapc (lambda (x) (delete-overlay x)) (car (overlay-lists)))
+ (mapc (lambda (x) (delete-overlay x)) (cdr (overlay-lists)))))
+
+ ;; Display the tabs
+
+ (widget-insert "\n Project configuration.\n
+ ___________ ____________ ____________ ____________ ____________\n / ")
+ (widget-create 'push-button :notify
+ (lambda (&rest dummy) (ada-prj-display-page 1)) "General")
+ (widget-insert " \\ / ")
+ (widget-create 'push-button :notify
+ (lambda (&rest dummy) (ada-prj-display-page 2)) "Paths")
+ (widget-insert " \\ / ")
+ (widget-create 'push-button :notify
+ (lambda (&rest dummy) (ada-prj-display-page 3)) "Switches")
+ (widget-insert " \\ / ")
+ (widget-create 'push-button :notify
+ (lambda (&rest dummy) (ada-prj-display-page 4)) "Ada Menu")
+ (widget-insert " \\ / ")
+ (widget-create 'push-button :notify
+ (lambda (&rest dummy) (ada-prj-display-page 5)) "Debugger")
+ (widget-insert " \\\n")
+
+ ;; Display the currently selected page
+
+ (cond
+
+ ;;
+ ;; First page (General)
+ ;;
+ ((= tab-num 1)
+ (widget-insert "/ \\/______________\\/______________\\/______________\\/______________\\\n")
+
+ (widget-insert "Project file name:\n")
+ (widget-insert (plist-get ada-prj-current-values 'filename))
+ (widget-insert "\n\n")
+; (ada-prj-field 'filename "Project file name"
+; "Enter the name and directory of the project
+; file. The name of the file should be the
+; name of the project itself. The extension
+; must be .adp")
+; (ada-prj-field 'casing "Casing Exceptions Dictionnaries"
+; "List of files that contain casing exception
+; dictionnaries. All these files contain one
+; identifier per line, with a special casing.
+; The first file has the highest priority."
+; t)
+ (ada-prj-field 'main "Executable file name"
+"Name of the executable generated when you
+compile your application. This should include
+the full directory name, using ${build_dir} if
+you wish.")
+ (ada-prj-field 'main_unit "File name of the main unit"
+"Name of the file to pass to the gnatmake command,
+and that will create the executable.
+This should not include any directory specification.")
+ (ada-prj-field 'build_dir "Build directory"
+ "Reference directory for relative paths in
+src_dir and obj_dir below. This is also the directory
+where the compilation is done.")
+ (ada-prj-field 'remote_machine "Name of the remote machine (if any)"
+"If you want to remotely compile, debug and
+run your application, specify the name of a
+remote machine here. This capability requires
+the 'rsh' protocol on the remote machine.")
+ (ada-prj-field 'cross_prefix "Prefix used in for the cross tool chain"
+"When working on multiple cross targets, it is
+most convenient to specify the prefix of the
+tool chain here. For instance, on PowerPc
+vxworks, you would enter 'powerpc-wrs-vxworks-'.
+To use JGNAT, enter 'j'.")
+ )