Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [cperl] Sub indentation trouble

Reply
Thread Tools

[cperl] Sub indentation trouble

 
 
Julien K.
Guest
Posts: n/a
 
      04-24-2009
Dear Emacs & Perl users,

[ This post is an updated version of a previous post on gnu.emacs.help that
didn't get any answer; sorry for those who read both groups]

I'm having trouble with 'sub' indentation with cperl mode (version > 4.32).
I think my problem does not depend on the emacs version but on cperl version
as I got the same behaviour on Linux and OsX both with last Emacs and XEmacs.

I'm using GNU-style indentation, the incorrect indentation happens after
the 'sub' closing statement.

With my current setting the following line is indented like the closing
brace of the 'sub':

<<<<<
sub mySub
{ my ($self) = @_ ;
# perl stuff
return ($var) ;
}
# Other stuff
sub myOtherSub
{ ...

^^ Extra indent
>>>>>


I'd like 'sub' block indentation be like 'foreach' or 'if' blocks, ie
return to column 0 for the next statement.

<<<<<
sub mySub
{ my ($self) = @_ ;
# perl stuff
return ($var) ;
}
# Other stuff
sub myOtherSub
{ ...
>>>>>


Any hints?

Cheers,

Julien
 
Reply With Quote
 
 
 
 
smallpond
Guest
Posts: n/a
 
      04-24-2009
On Apr 24, 9:04 am, "Julien K." <(E-Mail Removed)>
wrote:

> Any hints?



If emacs were written in perl and not lisp, then this would be an
excellent
in which to post your question.

Perhaps you want to modify the indent variables when loading perl-
mode.el?

Various indentation styles: K&R BSD BLK GNU LW
perl-indent-level 5 8 0 2 4
perl-continued-statement-offset 5 8 4 2 4
perl-continued-brace-offset 0 0 0 0 -4
perl-brace-offset -5 -8 0 0 0
perl-brace-imaginary-offset 0 0 4 0 0
perl-label-offset -5 -8 -2 -2 -2
 
Reply With Quote
 
 
 
 
Julien K.
Guest
Posts: n/a
 
      04-24-2009
On 24-04-2009, smallpond wrote:
> On Apr 24, 9:04 am, "Julien K." <(E-Mail Removed)>
> wrote:
>
>> Any hints?

>
> If emacs were written in perl and not lisp, then this would be an
> excellent in which to post your question.


I'm aware of the off-topic part (half?) of my question, but:

1/ the author of cperl (thank you very much for that code) seems to
read this newsgroup,
2/ Perl coders sometimes use (X?)Emacs
3/ Some of those coders may have run into the same trouble...

> Perhaps you want to modify the indent variables when loading perl-
> mode.el?
>
> Various indentation styles: K&R BSD BLK GNU LW
> perl-indent-level 5 8 0 2 4
> perl-continued-statement-offset 5 8 4 2 4
> perl-continued-brace-offset 0 0 0 0 -4
> perl-brace-offset -5 -8 0 0 0
> perl-brace-imaginary-offset 0 0 4 0 0
> perl-label-offset -5 -8 -2 -2 -2


That's what I tried before posting, based on informations from the cperl
minidocs but with not much luck, and to set cperl-close-paren-offset
to several negative values...

I also tried to track what changed before cperl-5.1 because my settings
did not changed during the past few years (if it's not broken...)

Thanks for your reply anyway,

Julien
 
Reply With Quote
 
Ilya Zakharevich
Guest
Posts: n/a
 
      04-25-2009
On 2009-04-24, Julien K. <(E-Mail Removed)> wrote:
> I also tried to track what changed before cperl-5.1 because my settings
> did not changed during the past few years (if it's not broken...)


All changes should be documented in cperl-mode.el.

Yours,
Ilya
 
Reply With Quote
 
Julien K.
Guest
Posts: n/a
 
      04-27-2009
On 25-04-2009, Ilya Zakharevich wrote:
> On 2009-04-24, Julien K. <(E-Mail Removed)> wrote:
>> I also tried to track what changed before cperl-5.1 because my settings
>> did not changed during the past few years (if it's not broken...)

>
> All changes should be documented in cperl-mode.el.


So let me rephrase this point:

I didn't find the change(s) that led to the modification in 'sub's
indentation within all the changes between cperl versions reported in the
beginning of cperl.el.

Cheers,

Julien
 
Reply With Quote
 
Julien K.
Guest
Posts: n/a
 
      04-29-2009
On 27-04-2009, Ilya Zakharevich wrote:
> On 2009-04-27, Julien K. <(E-Mail Removed)> wrote:
>>> All changes should be documented in cperl-mode.el.

>>
>> So let me rephrase this point:
>>
>> I didn't find the change(s) that led to the modification in 'sub's
>> indentation within all the changes between cperl versions reported in the
>> beginning of cperl.el.

>
> There should be something liek "Major rework of indentation engine".


Indeed, the cperl-5.0 indents subs with return to top-level, and the next
version available on your site does not.

So which variable should I customize to get the 5.0 behaviour back in
cperl-6.2?

> 1/4


???

Cheers,

Julien
 
Reply With Quote
 
Ilya Zakharevich
Guest
Posts: n/a
 
      04-29-2009
On 2009-04-29, Julien K. <(E-Mail Removed)> wrote:
>> There should be something liek "Major rework of indentation engine".

>
> Indeed, the cperl-5.0 indents subs with return to top-level, and the next
> version available on your site does not.


Sorry, I do not understand this sentence...

> So which variable should I customize to get the 5.0 behaviour back in
> cperl-6.2?


The simplest solution would be to switch to a sane indentation style.
I have no idea what you WANT to see with your examples. And until I
know what is the intent, I can't classify this as a bug.

>> 1/4


quarter of a smiley?

Ilya
 
Reply With Quote
 
Julien K.
Guest
Posts: n/a
 
      04-29-2009
On 29-04-2009, Ilya Zakharevich wrote:
> On 2009-04-29, Julien K. <(E-Mail Removed)> wrote:
>>> There should be something liek "Major rework of indentation engine".

>>
>> Indeed, the cperl-5.0 indents subs with return to top-level, and the next
>> version available on your site does not.

>
> Sorry, I do not understand this sentence...


I grabbed the differents cperl from this location:
<http://math.berkeley.edu/~ilya/software/emacs/>

As you said (and as I thought before my initial post the indentation
works ok for me up to cperl-5.0.

>> So which variable should I customize to get the 5.0 behaviour back in
>> cperl-6.2?

>
> The simplest solution would be to switch to a sane indentation style.


I use the GNU perl-style with various settings like
cperl-extra-newline-before-brace and cperl-extra-newline-before-brace-multiline
set to true. Isn't it sane enough ?

> I have no idea what you WANT to see with your examples.


Ok, I'll try to be more precise. I prefer the opening brace to be on a
separate line after the 'sub' statement. The closing brace of the 'sub'
declaration is on the same column that the opening one. So far so good.

But the next line _after_ the closing brace indents to the same column as
the closing brace itself:

<<<<
sub test
{ my ($self) = @_ ;
}
# the commment starts at col 2 instead of col 0
>>>>


The if/else/... blocks don't behave like that:
<<<<
if (test)
{
}
# comment that starts at col 0 -- ok
>>>>>


> And until I know what is the intent, I can't classify this as a bug.


I'm not sure it is a bug, maybe I didn't understand well the settings of
cperl.

I've been using cperl nearly every day for Perl programming for the
past five years, and I find it very useful. Thanks a lot for your work (and
now for your help).

Julien
 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      04-29-2009
>>>>> "JK" == Julien K <(E-Mail Removed)> writes:

JK> sub test
JK> { my ($self) = @_ ;
JK> }
JK> # the commment starts at col 2 instead of col 0

regardless of how you use cprerl mode, that is one fugly indent style!!



uri

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
Julien K.
Guest
Posts: n/a
 
      04-29-2009
On 29-04-2009, Uri Guttman wrote:
>>>>>> "JK" == Julien K <(E-Mail Removed)> writes:

>
> JK> sub test
> JK> { my ($self) = @_ ;
> JK> }
> JK> # the commment starts at col 2 instead of col 0
>
> regardless of how you use cprerl mode, that is one fugly indent style!!


Hey, this very scheme is what I want to get rid of. Otherwise after six or
seven "sub" declaration I'll be very close to the right side of the
screen...

BTW what's wrong with this in your opinion:
<<<<<
sub test
{ my ($self) = @_ ;
# stuff
return ($var) ;
}

sub _init
{ my $self = shift ;
# ...
}
>>>>>


I find this indent scheme very easy to read.

Julien
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
remove overall indentation preserving reletive indentation Jesse B. Ruby 2 03-27-2010 07:23 PM
asp.net Menu control: direction/indentation of sub-menus crayon Software 1 12-18-2007 09:00 PM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
asp.net Menu control: direction/indentation of sub-menus crayon ASP .Net 0 06-06-2007 11:49 AM



Advertisments