[Emacs-ada-mode] Adapting comp_cmd or make_cmd in my .emacs, NOT in some .adp (project) file

Stephen Leake stephen_leake at stephe-leake.org
Thu Oct 12 11:30:43 PDT 2006


Philippe Bertin <philippe.bertin at telenet.be> writes:

> When I google for a solution for my problem, I always encounter the 
> solution path related to using (emacs .adp) project files. However, I 
> would like to avoid using .adp project files alltogether.

Ok, that might be possible.

> I'd like to perform my compilations/makes based on the settings in my 
> ~/.emacs, and all of them should be made regardless of any .adp 
> settings. Because maintaining both a .gpr file and a .adp file will turn 
> into maintenance problems one day or another. 

Yes. We are exploring ways of solving that problem. Abandoning .adp
files altogether might be one way.

> I'd be using gnatmake and it's -P switch and a .gpr project file to
> compile/make in emacs, just as I do them on the command line.

Ok.

> I tried changing the ada mode by hooking onto ada-mode so that it would 
> look like (in this specific case, overriding the C-c C-c binding too) :
> (add-hook 'ada-mode-hook
>           (lambda()
>             (define-key ada-mode-map "\C-c\C-c" 'ada-compile-current)
>             (setq comp_cmd "gnatmake -c -Pmy_own_projects_dot_gpr_file.gpr")
>           ))

The problem here is that 'comp_cmd' is not the name of the Emacs lisp
variable that stores the ada-mode compile command; it is the name of
the project file option.

The ada-mode manual should explain this, but currently does not.

There is no simple lisp variable that contains "the Ada compile
command". Instead there is an association list that stores a set of
properties associated with each Emacs ada-mode project file.

The ada-mode variables you can set are listed in Customize; select
menu Options | Customize, then navigate thru Programming | Languages |
Ada - this needs to be better organized (more for me to do :).

Eventually you find "Ada Prj Default Comp Opt", which is the variable
'ada-prj-default-comp-opt'. You can add
"-Pmy_own_projects_dot_gpr_file.gpr" to that, in your .emacs.

Let me know if that works.

> (In a next phase, I'll of course want to change make_cmd too, in order 
> to be capable of using .gpr files for makes too)

The problem with this approach is that Emacs will not be able to find
the source files mentioned in compilation error messages, if they are
in multiple directories. That is the most important role of Emacs
ada-mode project files; as you point out, setting compiler options is
really the job of the GNAT project files (if you are using GNAT).

So I think you will start using Emacs ada-mode project files when you
get to larger projects. Automatically producing the .adp from the .gpr
might be a good solution at that point. Perhaps gpr2adp should have an
option to only output the search path.

As an intermediate solution, you can specify the GNAT project file in
the 'comp_cmd' setting (and in the other compile command settings) in a
.adp file, and use that one .adp file for all projects, by setting
'ada-prj-default-project-file' to that file in your .emacs.

Perhaps we should simplify that process; provide a 'gnat_prj_file'
setting in the .adp file or something.

At some point, you will want one .gpr file per project; there should
be a way for Emacs ada-mode to use that .gpr file automatically. I'll
think about it.

-- 
-- Stephe



More information about the Emacs-ada-mode mailing list