Ludovic Brenta <[email protected]> writes:

> Stephen Leake <[email protected]> writes:
>> Ludovic Brenta <[email protected]> writes:
>>
>>> With ada-mode 4 this works through a kludge in
>>> our ~/.emacs that requires 'ada-xref and creates an emacs Ada project in
>>> memory from $ADA_INCLUDE_PATH.
>>>
>>> With ada-mode 5, the project is only created by an ada-mode hook, after
>>> the first Ada file is loaded.
>>
>> This might be generally useful; can you post that hook? Perhaps I can
>> integrate it into ada-mode.
>
> Here it is:
>
> (add-hook 'ada-mode-hook
>           (lambda ()
>             (when (not ada-prj-current-file) ; no project file defined yet; 
> create one.
>               (let ((project-file (make-temp-file "default_" nil ".adp")))
>                 (save-current-buffer
>                   (let ((project-buffer (find-file-noselect project-file)))
>                     (set-buffer project-buffer)
>                     (dolist (var '("src_dir=" "obj_dir=" "build_dir="))
>                       (insert (concat var (directory-file-name (getenv 
> "PWD")) "\n")))
>                     (save-buffer 0)
>                     (setq buffer-read-only t)
>                     (ada-parse-prj-file project-file)
>                     (ada-select-prj-file project-file)
>                     (bury-buffer project-buffer)
>                     ; Now add a hook to delete the generated project file 
> when emacs exits.
>                     (add-hook 'kill-emacs-hook
>                               (lambda () (if (file-exists-p 
> ada-prj-current-file)
>                                              (delete-file 
> ada-prj-current-file))))))))))
>

It would be good to avoid the file; the user might be tempted to edit
it.

This could be done if ada-prj-default took a directory argument, used
that as the default for src_dir, and passed it as an arg to
ada-prj-default-list.

Then we could add a function ada-create-select-default-prj that creates
and selects the default project for the current directory.


'build_dir' and 'obj_dir' are not used by ada-mode code; what do
you use them for? They could occur in your values for
ada-build-{check|make|run}-cmd. 

You could add a function to ada-prj-default-list to define those prj
vars.

-- 
-- Stephe

_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org

Reply via email to