[Emacs-ada-mode] Thanks and my first enquiry

The masked-coder known as Randux randux at Safe-mail.net
Tue Aug 22 04:56:03 PDT 2006


My comments inside the text, after the relevant bits.

Cheers,
Randall

-------- Original Message --------
From: Stephen Leake <stephen_leake at stephe-leake.org>
Apparently from: emacs-ada-mode-bounces at stephe-leake.org
To: emacs-ada-mode at stephe-leake.org
Subject: Re: [Emacs-ada-mode] Thanks and my first enquiry
Date: Tue, 22 Aug 2006 06:04:31 -0400

> "The masked-coder known as Randux" <randux at Safe-mail.net> writes:
> 
> > Consider two hello_world programs, A and B, which are just a few
> > lines:
> >
> > with ada.text_io; use ada.text_io
> >
> > procedure helloa is
> >      begin
> >           put_line("Hello world, I'm program A!");
> > end helloa;
> >
> > and do likewise for b with procedure and file names modified
> > accordingly.
> >
> > Right, here's the scenario:
> >
> > 1. Create two hello_world programs, A and B.
> > 2. emacs helloa.adb
> > 3. C-x C-f hellob.adb
> > 4. make some modification to hellob.adb and save C-x C-s
> > 5. C-c C-c will now build hellob.adb (as desired)
> > 6. C-x k kills buffer hellob.adb and now helloa.adb is current
> > 7. make some modification to helloa.adb and save C-x C-s
> > 8. C-c C-c will now issue gnatmake on hellob.adb erroneously, instead
> > of helloa.adb
> 
> I agree this is unexpected behavior, and should be improved.
> 
> The issue is "how does Emacs Ada mode know what the 'current main
> program' is".

Perhaps this should not be the issue.  Perhaps ada-mode is trying to do too much.  When I do C-c C-c I would be delighted to have ada-mode simply do as I asked and issue a gnatmake on the current buffer.  I'll accept  responsibility for misusing gnatmake, etc.  This way things are much simpler.  There are also functions to compile (as Manuel pointed out). Once someone learns what he should be doing he can choose the right function himself. Just as I've different key bindings to go forward one character or one word in Emacs, it's perfectly fine if I've two key bindings, one for gnatmake and one for compile.  I think this is in keeping with the rest of the way Emacs works.

> The proper way to invoke gnatmake is to specify the main program,
> which may not be the current buffer when C-c C-c is invoked. Thus
> Emacs Ada mode has an internal variable that specifies the main
> program.

If it turns out that ada-mode having knowledge of buffer contents causes usability problems such as we discussed then perhaps it would be better to have a "dumber" ada-mode.

> The current behavior is that if that variable is not defined, the
> first invocation of C-c C-c sets the variable to the current file.
> After that, there doesn't seem to be a way to change it, short of
> loading a project file that sets it.

If the first invocation of C-c C-c sets the variable to the current file/buffer then why can't  subsequent invocations do exactly the same thing?

> In the scenario above, there aught to be an Emacs Ada mode command on
> the Ada menu that says "change the main program to the current file",
> which would be step 7.1. That should be fairly easy to implement; I'll
> work on it.

Perhaps my view is incorrect or irrelevant as I'm new to everything here and I also have no history with Ada mode or its goals.  That said, I think perhaps one of the problems with the current ada-mode is that it is too smart. I've always preferred to trade off automation for control as I like simple things. Having the right balance of smarts and simplicity is a difficult task to accomplish well.

Yes, if there's a project file associated with the current buffer (and how this should happen is probably also a matter of some debate) I agree with everyone that ada-mode should process according to the project file.  If there's not a project file association, why does ada-mode need to know what all the relationships are, what kind of source is in the buffer, and so on?  Why can't it simply do gnatmake on the current buffer?

I suppose this is a question of philosophy on the basic issue of what ada-mode is really about, isn't it then?  Is it supposed to create a full-on IDE for Ada using Emacs as the underpinnings, or is it supposed to add useful key bindings and shortcut functions to Emacs when an Ada file is being edited? Or something else entirely...

I would prefer the least possible automation.  It seems as making a true Ada IDE of Emacs isn't very likely given that people are working during most of their day and that if someone wants to make a new IDE then Emacs is not the best place to start.  The next best thing in my view is having a menu of useful functions bound to keys, that are performed when I select them.  I would prefer doing things manually as opposed to having ada-mode being required to have any knowledge of buffer contents or making any assumptions about what I'm trying to do. 

While adding a step such as you suggest will be one way to address the issue, it seems to me that this is just too complicated for what should be a simple situation.  I've something here in my edit buffer, I want to build it (this is the same scenario as J. P. Rosen is presenting).  It's my problem if I issue a gnatmake wastefully (for example on a subprogram). But ada-mode should just do as I ask and not try to figure out whether what I want makes sense.  It seems to me that this design approach could simplify things quite a bit both for implementing Ada mode and for programmers using Emacs to work with Ada.

Randall



More information about the Emacs-ada-mode mailing list