Dr Balwinder S Dheeman wrote:
> 
> Dear Rubiest!
> 
> I'm working on a Ruby source code formatting and, or beautification 
> utility (http://rindent.rubyforge.org/) for ruby programmers and, or 
> developers.
> 
> Hence, I'm looking forward to your valuable ideas on how do I format the 
> following code structures:
> 
> 1) *begin*
> 
> 1.1.1) as per matz:
> 
>     begin
>       expr..
>     [rescue [error_type,..]
>       expr..]..
>     [else
>       expr..]
>     [ensure
>       expr..]
>     end
> 
> 1.2.1) but I prefer:
> 
>     begin
>         expr..
>       [rescue [error_type,..]
>         expr..]..
>     [else        # a hanging 'else' clause
>       expr..]
>     [ensure      # a hanging 'ensure' clause
>       expr..]
>     end
> 
> 1.2.2) but I also like:
> 
>     begin
>         expr..
>       [rescue [error_type,..]
>         expr..]..
>       [else
>         expr..]
>       [ensure
>         expr..]
>     end
> 
> 
> 2) *case*
> 
> 2.1.1) as per matz:
> 
>     case expr
>     [when expr [, expr]...[then]
>       expr..]..
>     [else
>       expr..]
>     end
> 
> 2.2.1) but I prefer:
> 
>     case expr
>       [when expr [, expr]...[then]
>         expr..]..
>     [else    # a hanging 'else' clause
>       expr..]
>     end
> 
> 2.2.2) but I also like:
> 
>     case expr
>       [when expr [, expr]...[then]
>         expr..]..
>       [else
>         expr..]
>     end
> 
> 
> Whichever of above appeals you better? Or do any of you have better 
> ideas on these? What would you expact more from such a utility? Feedback 
> of yours shall highly be appreciated.
> 
> Regards,

my $0.02 ==> ever since Pascal I've formatted my code to make the block 
as a whole visible in one glance. Therefor I indent everything IN the 
block relative to the beginning of the block (that includes the "end" 
statement). That way my eyes can "travel" swiftly from block to block, a 
block simply ends where my eyes catch the next "out-dentation". It works 
for *me*...

 > 1.2.3) as per me:
 >
 >     begin
 >       expr..
 >     	[rescue [error_type,..]
 >         expr..]..
 >     	[else
 >         expr..]
 >     	[ensure
 >         expr..]
 >     	end

Since the rescue, else and ensure statements are at the level of the 
block, I put them at the same indentation. They can themselves "lead in" 
a block which will be indented relative to the lead in statement. Works 
like a charm, again, for *me*...

 > 2.2.3) as per me:
 >
 >     case expr
 >     	[when expr [, expr]...[then]
 >         expr..]..
 >     	[else
 >         expr..]
 >     	end
 >

Luc