[Emacs-ada-mode] [patch] Surround project file name with double-quotes

Stephen Leake stephen_leake at stephe-leake.org
Thu Nov 15 17:05:14 PST 2007


Ludovic Brenta <ludovic at ludovic-brenta.org> writes:

> Stephen Leake <stephen_leake at stephe-leake.org> writes:
>
>> Ludovic Brenta <ludovic at ludovic-brenta.org> writes:
>>
>>> On windows, my project files are in C:\Documents and Settings\... and
>>> the default compile and gnat find commands (C-u C-c C-c and C-r C-r
>>> respectively) fail because the command launched cannot find the project
>>> file.  The fix is to surround the project file name with double-quote
>>> characters, e.g. gnatmake -P"C:\Documents and Settings\...\f.gpr".
>>> The patch below does this unconditionally because the double-quote
>>> characters are harmless even if they are not necessary.
>>
>> Right. There are a couple other uses of the project file as well.
>>
>>> another fix in this patch is the use of the variable ada-gnat-cmd
>>> instead of hardcoded "gnat" in "gnat find".  This is handy when you
>>> don't have a native GNAT installed but only a cross gnat, e.g.
>>> powerpc-wrs-vxworks-gnat.
>>
>> That makes sense in general, but it violates the intended use of this
>> variable, which is to allow "gnatpath" to replace "gnat" when parsing
>> project files. Obviously, the name of the variable could be improved
>> :(. I don't want to change it, though, since that would break current
>> setups. 
>
> I believe Emacs Lisp allows you to override the value of the variable
> locally in the defun where you call gnatpath.  Or else, you might as
> well hardcode "gnatpath" in that defun, right?

It's a user option; if they want, they can install gnatpath, and set
ada-gnat-cmd to it. Otherwise, ada-gnat-cmd defaults to "gnat".

> No, I never used gnatpath.  I open one project and, yes, the parsing
> using "gnat list" is a bit slow, but I don't care because I then leave
> emacs running for days on end with that one project open.

Ok.

>> Back to your issue of specifying the gnat executable name; you should
>> set the 'cross-prefix' Emacs project file variable, and then I should
>> fix ada-xref.el to use it more consistently (just done in my version).
>
> Ah, thanks.  But a fix is still needed in ada-find-any-references to
> take advantage of the cross-prefix.  

Is that still true in 3.9? I thought I caught all the uses of "gnat".

> However I do not use Emacs project files at all, only .gpr files.
> How can I set cross-prefix? I do not see it defined as a variable,
> only as a property in the project and AFAICT the only way to set it,
> currently, is by means of an Emacs project file.

Hmm. That's not simple with the current code (3.9).

We would need to add a lisp variable that is referenced in
ada-default-prj-properties. That would not be bad.

Unless that is done, the answer is "use an Emacs project file".

I load the Emacs project file automatically from my Makefile:

# Local Variables:
# eval: (ada-parse-prj-file "gds.prj")
# eval: (ada-select-prj-file "gds.prj")

I keep 'parse' and 'select' separate so I can parse several files, and
then go back and choose which to use by re-running 'select'.

If you have only one project, just put this in your .emacs and forget
about it.

-- 
-- Stephe



More information about the Emacs-ada-mode mailing list