Skip Menu |

This queue is for tickets about the Perl-Tidy CPAN distribution.

Report information
The Basics
Id: 81852
Status: resolved
Priority: 0/
Queue: Perl-Tidy

People
Owner: Nobody in particular
Requestors: parlay [...] yopmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Stacked containers and quoting operators
This is the output format I want: DB->do(qq( CREATE INDEX IF NOT EXISTS idx_account_user_payment ON AccountPayment(user, payment); )); This is what perltidy turns it into: DB->do( qq( CREATE INDEX IF NOT EXISTS idx_account_user_payment ON AccountPayment(user, payment); ) ); I tried all the different stacking options, with no effect.
From: justincase [...] yopmail.com
On Sun Dec 09 17:56:05 2012, parlay wrote: Show quoted text
> This is the output format I want: > > DB->do(qq( > CREATE INDEX IF NOT EXISTS idx_account_user_payment > ON AccountPayment(user, payment); > )); > > This is what perltidy turns it into: > > DB->do( > qq( > CREATE INDEX IF NOT EXISTS idx_account_user_payment > ON AccountPayment(user, payment); > ) > ); > > I tried all the different stacking options, with no effect.
I think this is the same bug I ran into. Original, and preferred format: my @morse = ( [qw( .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----. )], [qw( ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----. .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. )], ); Results in the following: my @morse = ([ qw( .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----. ) ], [ qw( ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----. .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. ) ], ); Using the following options: --continuation-indentation=4 --paren-tightness=2 --block-brace-tightness=1 --nospace-for-semicolon --opening-token-right --stack-all-containers --stack-opening-block-brace --weld-nested-containers
Subject: Re: [rt.cpan.org #81852] Stacked containers and quoting operators
Date: Thu, 1 Feb 2018 08:23:48 -0800
To: bug-Perl-Tidy [...] rt.cpan.org
From: Steven Hancock <s7078hancock [...] gmail.com>
The desired formatting here is what the -wn flag would normally give. The problem is that the opening and closing parens of all types of quotes in perltidy are treated as special quote delimiter characters and cannot be controlled by the normal controls for braces, parens and brackets. The formatting will be the same if the quote delimiter characters are parens, braces, or even an exclamation mark for example. So, unfortunately, the -wn flag does not work in this case. It would be difficult to change this. Incidentally, note that the first example uses a qq quote operator and the second uses a qw quote. For the qq quote, any whitespace before the terminal quote delimiter is unchanged by perltidy, so since this character was unindented in the input file it remains unindented in the output file. Steve On Wed, Jan 31, 2018 at 5:41 PM, Justin Case via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81852 > > > On Sun Dec 09 17:56:05 2012, parlay wrote:
> > This is the output format I want: > > > > DB->do(qq( > > CREATE INDEX IF NOT EXISTS idx_account_user_payment > > ON AccountPayment(user, payment); > > )); > > > > This is what perltidy turns it into: > > > > DB->do( > > qq( > > CREATE INDEX IF NOT EXISTS idx_account_user_payment > > ON AccountPayment(user, payment); > > ) > > ); > > > > I tried all the different stacking options, with no effect.
> > I think this is the same bug I ran into. Original, and preferred format: > > my @morse = ( > [qw( > .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- > .--. --.- > .-. ... - ..- ...- .-- -..- -.-- --.. ----- .---- ..--- ...-- > ....- > ..... -.... --... ---.. ----. > )], > [qw( > ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----. .- > -... > -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- > .-. ... > - ..- ...- .-- -..- -.-- --.. > )], > ); > > Results in the following: > > my @morse = ([ qw( > .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. > --- .--. --.- > .-. ... - ..- ...- .-- -..- -.-- --.. ----- .---- ..--- > ...-- ....- > ..... -.... --... ---.. ----. > ) > ], [ qw( > ----- .---- ..--- ...-- ....- ..... -.... --... ---.. > ----. .- -... > -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. > --.- .-. ... > - ..- ...- .-- -..- -.-- --.. > ) > ], > ); > > Using the following options: > > --continuation-indentation=4 > --paren-tightness=2 > --block-brace-tightness=1 > --nospace-for-semicolon > --opening-token-right > --stack-all-containers > --stack-opening-block-brace > --weld-nested-containers > >
perltidy version 20181117 with the -wn flag can do this now.
On Sat Nov 17 15:10:05 2018, SHANCOCK wrote: Show quoted text
> perltidy version 20181117 with the -wn flag can do this now.
Using the same options and examples as mentioned above, I'm now seeing the following results. Note the extra internal indentation and closing container brackets don't align with the opening brackets. # Example 1 DB->do(qq( CREATE INDEX IF NOT EXISTS idx_account_user_payment ON AccountPayment(user, payment); )); # Example 2 my @morse = ( [qw( .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----. )], [qw( ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----. .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. )], );
I don't see extra internal indentation. Note that any spacing within qq quotes is part of a fixed quote and not touched in formatting. So whatever whitespace is at the start of the lines within a qq quote remains unchanged. For lining up closing parens, what happens here is that since they occur within a continuing list they are getting indented by the amount of the 'continuation indentation', which is set to 4 spaces in this case. So they are not getting lined up the way you prefer. There is no control for this but it should not be hard to add one. I will look into it.
On Sun Nov 18 14:05:14 2018, SHANCOCK wrote: Show quoted text
> > I don't see extra internal indentation. Note that any spacing within > qq quotes is part of a fixed > quote and not touched in formatting. So whatever whitespace is at the > start of the lines within > a qq quote remains unchanged.
For both examples, using the options above, the contents of the outer parens have a single extra indentation of 4 spaces. Examples showing only the opening to highlight the extra level of indentation: Before: my @morse = ( [qw( .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- After: my @morse = ( [qw( .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- Before: DB->do(qq( CREATE INDEX IF NOT EXISTS idx_account_user_payment After: DB->do(qq( CREATE INDEX IF NOT EXISTS idx_account_user_payment
version 20190601 has an update for this case