Georg Bauhaus <[email protected]> writes:

> There would be two kinds of skeletons.
>
> 1. The first sort of templates could work the old way and insert complete
> text that is syntactically correct. The skeletons "ada-package-spec"
> and "ada-header-tmpl" are of this sort, in my little draft, that is.
> They ask for some names, interactively.

I don't like interactive prompts; they interrupt the flow.

For example, in Else (the template package I'm reluctantly giving up
on), you type "procedure" then C-e. That gives a menu (hmm, an
interactive prompt; but I don't have to type a name), allowing choice
of spec or body. Body expands to:

procedure {designator} [formal_part]
is
   [declarative_item]...
begin
   {statement}...
[exception_part]
end [designator];

Now when I type a name into the first {designator}, it is automagically
copied to the second. Very nice.

Maybe we can add that mechanism to skeleton?

In addition, each of the bracketed items (called "placeholders") has
comment syntax, so the parser ignores them. Which means this particular
template is illegal syntax, which is one motivation for allowing almost
everything (not keywords) to be empty. (this template is accepted by the
SMIE parser, sigh).

> 2. The small selection of other templates that I have used for trying
> the idea would have the flavor of completion. I have simplified them
> WRT use of skeleton language. Thus, when a user has written
>
>   procedure X is
>
> and if the user then requests a template for the subprogram body,
> this request should evolve into the call
>
>  (ada-stmt-place-skeleton 'ada-subprogram-body nil '("X"))
>
> where "X" is the name that the parser has seen. Has it, at all?

No, since the fragment is not legal syntax, the parser does not know
about X yet.

You can insert the body template without the name following 'end', then
parse (and indent), then retrieve the name (via ada-which-function) and
insert it.

> The NIL indicates a minimal template. Other values will trigger
> more expansive additions like an exception handler. (The usual
> C-u modifier could be used for the distinction.) 

In the Else template above, [] indicates an optional item, which is
easily deleted with C-c C-k. C-e expands any placeholder to another
template, usually thru a menu.

> If more names are needed in this case and the parser cannot supply
> them, then ada-stmt-place-skeleton will construct dummy names.

"dummy names" are placeholders in the Else system; much easier to
recognize and replace. When you type on {designator}, the template is
the string "{designator}" is first deleted, then what you type replaces
it. 

Ideally, the Else template system implements the complete grammar, so
you can write any program by repeating C-e and typing names :). Hmm.
That suggests that the template system should be defined by parsing
ada-grammar.wy ... more work :)

Maybe I should just fix Else :).

But I should try skeleton first, since it is already part of Emacs. And
then work on improving it, before giving up :).

> Retrieving buffer positions from skeleton.el has been a partial
> success, that of the end of inserted seems to fail. These would be
> good for triggering indentation of the text inserted, as using `>'
> from the template language is not working during insertion, the text
> being incomplete.

Can you use indent-region after a complete statement? We could add
ada-indent-statement (I thought I had already). Maybe call that from
seleton-end-hook? 


I'm missing something fundamental about skeleton. I don't see any
"define-key" statements related to skeleton, so I don't know how to
experiment. How/when is a skeleton invoked? Can you give a small
tutorial, showing all keystrokes required to create a Hello_World
procedure?

-- 
-- Stephe

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

Reply via email to