Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Why does perltidy mess up whitespace before inline comments and equals?

by LanX (Saint)
on Oct 20, 2014 at 11:25 UTC ( [id://1104422]=note: print w/replies, xml ) Need Help??


in reply to Why does perltidy mess up whitespace before inline comments and equals?

Could you please be more specific about what you consider "unexpected changes" and what your desired output looks like?

your option -nolc mentions comments, searching the docs for -nolc shows

-olc, --outdent-long-comments When -olc is set, lines which are full-line (block) comments longe +r than the value maximum-line-length will have their indentation remo +ved. This is the default; use -nolc to prevent outdenting.

so what is your question?

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

Replies are listed 'Best First'.
Re^2: Why does perltidy mess up whitespace before inline comments and equals?
by will_ (Scribe) on Oct 20, 2014 at 13:30 UTC
    Rolf, I would expect those lines not to change at all.
    Eily, thanks -msc pointed me in the right direction.

    After some more experimenting, I've found that this code:
    $d->{status} = 'queued'; # something $d->{description} = 'The action'; # other thing $d->{id} = '12345'; # Identifies action
    gets changed to this:
    $d->{status} = 'queued'; # something $d->{description} = 'The action'; # other thing $d->{id} = '12345'; # Identifies action
    ...which is definitely better in that case.

    But even if only the last line had a comment and I use -msc=1:
    $d->{status} = 'queued'; $d->{description} = 'The action'; $d->{id} = '12345'; # Identifies action
    ...it still pushes the comment way out to the right to align with some non-existent other comments. That's not necessary.
    $d->{status} = 'queued'; $d->{description} = 'The action'; $d->{id} = '12345'; # Identifies action

    Setting -ols/-nolc don't seem to have any effect on this.

    And now I've found what I was looking for:
    -ssc -sscp=#
    This sets "static side comments", and sets the identifier for those to the usual # character

    docs: http://perltidy.sourceforge.net/perltidy.html#static_side_comments

    This lines up the equals but leaves the comments alone. The only time the equals doesn't get lined up is if that would make the line longer than the -l setting, which is fair enough.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-19 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found