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))))))))))

--
Ludovic Brenta.

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

Reply via email to