my %default = (
amount => 0,
balance => 0,
total_items => 0,
trade_disc => 0,
debit => 1
);
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
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
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.
> 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?
John, better don't care about the FUD metaperl spreads. 8)
Feeding the trolls is a waste of time...
I don't know about cperl, but align seams to have a ready to use rule
for this. Try `align-current'.
-ap
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
I'll gladly accept well-coded patches. (This is a recurring request
from the users.)
Yours,
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
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
> 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
> 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