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

cperl-mode

31 views
Skip to first unread message

Terrence Brannon

unread,
May 21, 2010, 4:09:20 PM5/21/10
to
Hi, would someone share their cperl-mode settings with me that will
format a hash like this
( http://pastebin.com/dfQKjXkS )

my %default = (
amount => 0,
balance => 0,
total_items => 0,
trade_disc => 0,
debit => 1
);

Stefan Monnier

unread,
May 23, 2010, 8:42:23 PM5/23/10
to

Don't know about cperl-mode, but perl-mode does it almost like you ask:

my %default = (
amount => 0,
balance => 0,
total_items => 0,
trade_disc => 0,
debit => 1
);

This last line looks like a bug, indeed.


Stefan

John Bokma

unread,
May 23, 2010, 11:36:54 PM5/23/10
to
Terrence Brannon <meta...@gmail.com> writes:

Start your region with the first =, and end it with the final one and
press:

C-M-| (cperl-lineup)

Note that the region /must start/ with =

--
John Bokma j3b

Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development

Terrence Brannon

unread,
May 24, 2010, 9:48:47 AM5/24/10
to
On May 23, 11:36 pm, John Bokma <j...@castleamber.com> wrote:

> Terrence Brannon <metap...@gmail.com> writes:
> > Hi, would someone share their cperl-mode settings with me that will
> > format a hash like this
> >  (http://pastebin.com/dfQKjXkS)
>
> > my %default = (
> >     amount      => 0,
> >     balance     => 0,
> >     total_items => 0,
> >     trade_disc  => 0,
> >     debit       => 1
> > );
>
> Start your region with the first =, and end it with the final one and
> press:

are you not familar with cperl-set-style?

also I have a perltidy callout that does it as well...

I think I will ask jonathan rockway about this, since he is officially
taking over cperl-mode for future releases.

John Bokma

unread,
May 24, 2010, 4:32:07 PM5/24/10
to
Terrence Brannon <meta...@gmail.com> writes:

> On May 23, 11:36 pm, John Bokma <j...@castleamber.com> wrote:
>> Terrence Brannon <metap...@gmail.com> writes:
>> > Hi, would someone share their cperl-mode settings with me that will
>> > format a hash like this
>> >  (http://pastebin.com/dfQKjXkS)
>>
>> > my %default = (
>> >     amount      => 0,
>> >     balance     => 0,
>> >     total_items => 0,
>> >     trade_disc  => 0,
>> >     debit       => 1
>> > );
>>
>> Start your region with the first =, and end it with the final one and
>> press:
>
> are you not familar with cperl-set-style?

I am quite new to Emacs, so I am not familiar with a lot of things. But
is there a style that does this automatically?

Or else: what do you want to tell me?

LanX

unread,
May 24, 2010, 5:12:53 PM5/24/10
to
> > are you not familar with cperl-set-style?
>
> I am quite new to Emacs, so I am not familiar with a lot of things. But
> is there a style that does this automatically?
>
> Or else: what do you want to tell me?

John, better don't care about the FUD metaperl spreads. 8)

Feeding the trolls is a waste of time...

Andreas Politz

unread,
May 24, 2010, 5:45:09 PM5/24/10
to
Terrence Brannon <meta...@gmail.com> writes:

I don't know about cperl, but align seams to have a ready to use rule
for this. Try `align-current'.

-ap

John Bokma

unread,
May 24, 2010, 6:11:48 PM5/24/10
to
LanX <lanx...@googlemail.com> writes:

OK, thanks for the heads up. I am still an Emacs newbie, and thought I
was missing something.

LanX

unread,
May 25, 2010, 6:36:11 AM5/25/10
to
> OK, thanks for the heads up. I am still an Emacs newbie, and thought I
> was missing something.

The only thing that you were missing is that Terrence aka Metaperl aka
Princepawn seems far to cool for a serious discussion.

People are trying here to figure out what he exactly wants in this
thread simply named cperl-mode.

Is it the line indentation in a multiline hash literal ???

Or is it the alignment of the fat comma ("=>") ???

cperl-set-style doesn't affect any of these, you have to look into the
documentation or try them out to see it.

And IMHO J.Rockway is just publishing a fork to support modules like
Moose and Devel::REPL, he is not the new maintainer.

Don't know if this "splitted personality" really intends to be a
troll, but he certainly has a talent in spreading confusion.
(just go to perlmonks and look at his list of worst posts)

So better ignore him as long he doesn't posts precise informations, if
you don't wanna waste your time.

(seems like that is what Ilya actually does)


Now, to give this discussion a productive turn here is the part of
cperl-mode.el which IMHO affects the line indentation:

----------
((eq 'in-parens (elt i 0))
;; in-parens char-after old-indent-point is-brace containing-sexp

;; group is an expression, not a block:
;; indent to just after the surrounding open parens,
;; skip blanks if we do not close the expression.
(+ (progn
(goto-char (elt i 2)) ; old-indent-point
(current-column))
(if (and (elt i 3) ; is-brace
(eq (elt i 1) ?\})) ; char-after
;; Correct indentation of trailing ?\}
(+ cperl-indent-level cperl-close-paren-offset)
0)))
--------

Would be nice if Ilya (or someone else) could add a new option to not
indent after surrounding parens, I have only limited resources to do
it right now.

for the moment an extra newline is the best workaround for a dense
indentation.

------------


my %default =
(
amount => 0,
balance => 0,
total_items => 0,
trade_disc => 0,
debit => 1
);

-------------

cheers
rolf

Ilya Zakharevich

unread,
May 26, 2010, 1:20:23 AM5/26/10
to
On 2010-05-25, LanX <lanx...@googlemail.com> wrote:
> Would be nice if Ilya (or someone else) could add a new option to not
> indent after surrounding parens, I have only limited resources to do
> it right now.

I'll gladly accept well-coded patches. (This is a recurring request
from the users.)

Yours,
Ilya

LanX

unread,
May 26, 2010, 8:41:24 AM5/26/10
to

Hi Ilya

> I'll gladly accept well-coded patches. (This is a recurring request
> from the users.)


talking about "well coded", I'm still a beginner in elisp and
sometimes wondering about your code.

You use and handle around quite often array like lists where every
index represents something specific which needs to be documented each
time you access it.

for instance in the posted code:
-----------


((eq 'in-parens (elt i 0))

...


(goto-char (elt i 2)) ; old-indent-point

...


(if (and (elt i 3) ; is-brace

-----------
where i is the return value from cperl-sniff-for-indent'

So why don't you use alists or even hashes instead of documenting each
numerical index?

http://www.gnu.org/s/emacs/manual/html_node/elisp/Association-Lists.html

Are there technical reasons for avoiding alists?

And wouldn't calling the variable something like "sniff" improve the
readability?

Cheers
Rolf

Ilya Zakharevich

unread,
May 26, 2010, 4:33:00 PM5/26/10
to
On 2010-05-26, LanX <lanx...@googlemail.com> wrote:
> So why don't you use alists or even hashes instead of documenting each
> numerical index?
>
> http://www.gnu.org/s/emacs/manual/html_node/elisp/Association-Lists.html
>
> Are there technical reasons for avoiding alists?

I have no idea. All I know is that elisp is very much pessimized; for
the speed reasons, I would prefer to use simplest constructs (the
initial version could have been hundreds times slower than the current
one; I was forced to change the whole framework how stuff operates on
the C level of Emacs).

There may be some benchmarks around; I just do not know about them.
(But this late in development cycle, I doubt I would change such
things now.)

Yours,
Ilya

LanX

unread,
May 26, 2010, 5:13:27 PM5/26/10
to
Hi

> I have no idea.  All I know is that elisp is very much pessimized; for
> the speed reasons, I would prefer to use simplest constructs (the
> initial version could have been hundreds times slower than the

OK, just wanna understand not criticize.

> (But this late in development cycle, I doubt I would change such
> things now.)

IMHO refactoring gradually to a macro construct should do it safely
and fast, something like (value i keyname) translating to (elt i
keyindex)


> There may be some benchmarks around; I just do not know about them.

Hmm do you have any automated testing framework, e.g. for syntax
parsing?

Cheers
Rolf

Ilya Zakharevich

unread,
May 27, 2010, 3:01:59 AM5/27/10
to
On 2010-05-26, LanX <lanx...@googlemail.com> wrote:
>> There may be some benchmarks around; I just do not know about them.

> Hmm do you have any automated testing framework, e.g. for syntax
> parsing?

x) I meant array vs vector vs hash etc benchmarks;

x) No. ;-)

Yours,
Ilya

0 new messages