Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How does ''surround'' work?

0 views
Skip to first unread message

Chris

unread,
Aug 6, 2008, 12:02:27 PM8/6/08
to
I have this three indented lines:

for i := 1 to 10 do begin
DoSomething;
end {for};

If I select them, and right-click ''surround tryf'', I get this:

try
for i := 1 to 10 do begin
DoSomething;
end {for};

finally
end;

The selected code indentation is increased, which is correct, but the
try/finally/end is not indented at the former code indentation. Is that the
intended behaviour?

I would have expected this:

try
for i := 1 to 10 do begin
DoSomething;
end {for};
finally
end;

Chris


Peter Below (TeamB)

unread,
Aug 7, 2008, 5:53:42 AM8/7/08
to
Chris wrote:

> I have this three indented lines:
>
> for i := 1 to 10 do begin
> DoSomething;
> end {for};
>
> If I select them, and right-click ''surround tryf'', I get this:
>
> try
> for i := 1 to 10 do begin
> DoSomething;
> end {for};
>
> finally
> end;
>
> The selected code indentation is increased, which is correct, but the
> try/finally/end is not indented at the former code indentation. Is
> that the intended behaviour?

The resulting alignment is a bit random <g>, the template engine is not
quite up to the task here. If you select comlete lines you get what you
observered, with the try..finally positioned in column 0. If you start
the selection on the "f" of the for and extend it to the semicolon
after the end comment you get something a bit closer to what one would
expect: the finally end is aligned on the old column of the for but the
try ends up directly above the for, so one indentation level to far to
the right.

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com

Gerrit Beuze

unread,
Aug 7, 2008, 7:08:02 AM8/7/08
to
Hello Chris,

> The selected code indentation is increased, which is correct, but the try/finally/end is not indented at the former code
> indentation. Is that the intended behaviour?


As Peter mentioned : " The resulting alignment is a bit random "

If you want better surround templates, check ModelMaker Code Explorer:
http://www.modelmakertools.com/code-explorer/index.html

This allows controlling the indent per template (and even unindent the template)
allows surrounds in a single line (FreeAndNil(..), Format(...)
and has two dedicated surrounds:

try finally wizard: this inserts finalization code based on the code before try.
block wizard: this surrounds a selection with a beginend bloc, determining
the indent automatically.

Both and several other "minor" features are demo-ed in this movie:
http://modelmakertools.com/movies/beyond-templates.htm
The try finally wizard is at about 3/4...


Gerrit Beuze
ModelMaker Tools


0 new messages