Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'd consider this indentation of CPerl to be a bug.

CPerl mode's M-x indent-region does more than just indent, it also tries to "fix" spacing. But in this case it turns out just horribly wrong. Here's an example to show the intention: If you type the following:

if($fee){fie()}else{foe($foo)}

...and then process this with M-x indent-region, then you get (depending on your style, I'm using PBP here):

if ($fee) { fie(); } else { foe($foo); }

Nifty, eh? A real life saver... but only if your space key is broken.

The customization variable responsible for this is cperl-indent-region-fix-constructs (on by default), which is out of the scope of the predefined indentation styles. The documentation for that variable shows what it should do, but not what it actually does. So, if you don't need CPerl mode to reformat your code like this, then I suggest you just turn off that variable as a workaround (and, if you like, write a bug report).

By the way: Emacs can help with aligning the keys as suggested by ikegami and GrandFather, unrelated to CPerl mode. It is hardly worth the effort for four lines, though: Mark the assignment as a region, and then

align-regexp<RET>name<RET> align-regexp<RET>class<RET>

This yields:

my @headings = ( {key => 'k', name => 'Kanji', class => 'kanji'}, {key => 'skip', name => 'SKIP', class => 'skip-code'}, {key => 'co', name => 'Suggestion', class => 'skip-code'}, {key => 'disc', name => 'Discussion'}, )

In reply to Re: How would you indent this? by haj
in thread How would you indent this? by no longer just digit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found