Quantcast

cperl-mode

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

cperl-mode

Terrence Brannon
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
);

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

LanX-2
> > 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...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

Andreas Politz, INF|INF-I
In reply to this post by Terrence Brannon
Terrence Brannon <[hidden email]> 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
> );

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

-ap
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

John Bokma
In reply to this post by LanX-2
LanX <[hidden email]> writes:

>> > 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...

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

--
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

LanX-2
> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

Ilya Zakharevich
On 2010-05-25, LanX <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

LanX-2

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

Ilya Zakharevich
On 2010-05-26, LanX <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

LanX-2
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cperl-mode

Ilya Zakharevich
On 2010-05-26, LanX <[hidden email]> 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
Loading...