Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLz8i-0006Sl-Mk for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jun 2017 21:50:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dLz8h-0005P7-Uw for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jun 2017 21:50:47 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dLz78-0002d8-RF for pgsql-hackers@postgresql.org; Fri, 16 Jun 2017 21:49:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dLz71-0005ac-Hq for pgsql-hackers@postgresql.org; Fri, 16 Jun 2017 21:49:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v5GLmnvu010043; Fri, 16 Jun 2017 17:48:49 -0400 From: Tom Lane To: Piotr Stefaniak cc: Andres Freund , Bruce Momjian , Peter Eisentraut , Alvaro Herrera , Robert Haas , "Stephen Frost" , "pgsql-hackers@postgresql.org" Subject: Re: Preliminary results for proposed new pgindent implementation In-reply-to: References: <20170519173111.zp6igkcg53egdy4s@alvherre.pgsql> <29275.1497624664@sss.pgh.pa.us> <8827.1497633050@sss.pgh.pa.us> <20170616171946.qqy5tapovsamkxyg@alap3.anarazel.de> <9900.1497634441@sss.pgh.pa.us> <20170616174430.GQ11450@momjian.us> <20170616180212.4yk44vso3n24bfns@alap3.anarazel.de> <11868.1497636718@sss.pgh.pa.us> Comments: In-reply-to Piotr Stefaniak message dated "Fri, 16 Jun 2017 21:05:27 -0000" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <10013.1497649687.0@sss.pgh.pa.us> Date: Fri, 16 Jun 2017 17:48:49 -0400 Message-ID: <10042.1497649729@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10013.1497649687.1@sss.pgh.pa.us> Piotr Stefaniak writes: > On 2017-06-16 20:11, Tom Lane wrote: >> I assume though that Piotr wants an option to preserve that behavior. >> I'm happy to write up a patch for bsdindent that adds a switch >> controlling this, but is there any rhyme or reason to the way its >> switches are named? > I don't want to preserve the current behavior at all, but I might need > to add an option for choosing one or the other if users of FreeBSD > indent protest. > I don't have a good name for it. The best I can do is -lpl ("-lp long > lines too"). Can I see the patch? Here's a patch. An alternative switch name might be -lpa ("-lp always") but I'm not set on that. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="indent-lpl.patch"; charset="us-ascii" Content-ID: <10013.1497649687.2@sss.pgh.pa.us> Content-Description: indent-lpl.patch Content-Transfer-Encoding: quoted-printable diff -pudr indent-curr/args.c indent-lpl/args.c --- indent-curr/args.c 2017-06-16 11:06:53.329712682 -0400 +++ indent-lpl/args.c 2017-06-16 17:43:56.473230024 -0400 @@ -125,6 +125,7 @@ struct pro { {"i", PRO_INT, 8, 0, &ps.ind_size}, {"lc", PRO_INT, 0, 0, &block_comment_max_col}, {"ldi", PRO_INT, -1, 0, &ps.local_decl_indent}, + {"lpl", PRO_BOOL, false, ON, &lineup_to_parens_always}, {"lp", PRO_BOOL, true, ON, &lineup_to_parens}, {"l", PRO_INT, 78, 0, &max_col}, {"nbacc", PRO_BOOL, false, OFF, &blanklines_around_conditional_compila= tion}, @@ -143,6 +144,7 @@ struct pro { {"nfc1", PRO_BOOL, true, OFF, &format_col1_comments}, {"nfcb", PRO_BOOL, true, OFF, &format_block_comments}, {"nip", PRO_BOOL, true, OFF, &ps.indent_parameters}, + {"nlpl", PRO_BOOL, false, OFF, &lineup_to_parens_always}, {"nlp", PRO_BOOL, true, OFF, &lineup_to_parens}, {"npcs", PRO_BOOL, false, OFF, &proc_calls_space}, {"npro", PRO_SPECIAL, 0, IGN, 0}, diff -pudr indent-curr/indent.1 indent-lpl/indent.1 --- indent-curr/indent.1 2017-06-16 17:18:05.697722416 -0400 +++ indent-lpl/indent.1 2017-06-16 17:26:53.203823690 -0400 @@ -74,6 +74,7 @@ .Op Fl \&lc Ns Ar n .Op Fl \&ldi Ns Ar n .Op Fl \&lp | Fl nlp +.Op Fl \&lpl | Fl nlpl .Op Fl npro .Op Fl P Ns Ar file .Op Fl pcs | Fl npcs @@ -388,6 +389,19 @@ p1\ =3D\ first_procedure(second_procedure( \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4, \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ = p5)); .Ed +.It Fl \&lpl , nlpl +With +.Fl \&lpl , +code surrounded by parentheses in continuation lines is lined up even if it +would extend past the right margin. +With +.Fl \&nlpl +(the default), such a line that would extend past the right margin is moved +left to keep it within the margin, if that does not require placing it to +the left of the prevailing indentation level. +These switches have no effect if +.Fl nlp +is selected. .It Fl npro Causes the profile files, .Sq Pa ./.indent.pro diff -pudr indent-curr/indent.c indent-lpl/indent.c --- indent-curr/indent.c 2017-06-13 11:53:59.474524563 -0400 +++ indent-lpl/indent.c 2017-06-16 17:29:11.924267996 -0400 @@ -160,6 +160,7 @@ main(int argc, char **argv) #ifdef undef max_col =3D 78; /* -l78 */ lineup_to_parens =3D 1; /* -lp */ + lineup_to_parens_always =3D 0; /* -nlpl */ ps.ljust_decl =3D 0; /* -ndj */ ps.com_ind =3D 33; /* -c33 */ star_comment_cont =3D 1; /* -sc */ diff -pudr indent-curr/indent_globs.h indent-lpl/indent_globs.h --- indent-curr/indent_globs.h 2017-06-16 11:06:53.329712682 -0400 +++ indent-lpl/indent_globs.h 2017-06-16 17:30:14.664826384 -0400 @@ -185,6 +185,8 @@ int continuation_indent;/* set t * code and continuation lines */ int lineup_to_parens; /* if true, continued code within parens will * be lined up to the open paren */ +int lineup_to_parens_always; /* if true, do not attempt to keep + * lined-up code within the margin */ int Bill_Shannon; /* true iff a blank should always be inserted * after sizeof */ int blanklines_after_declarations_at_proctop; /* This is vaguely diff -pudr indent-curr/io.c indent-lpl/io.c --- indent-curr/io.c 2017-06-13 11:53:59.475524587 -0400 +++ indent-lpl/io.c 2017-06-16 17:31:11.233230896 -0400 @@ -221,6 +221,8 @@ compute_code_target(void) if (!lineup_to_parens) target_col +=3D continuation_indent * (2 * continuation_indent =3D=3D ps.ind_size ? 1 : ps.paren_level); + else if (lineup_to_parens_always) + target_col =3D paren_target; else { int w; int t =3D paren_target; ------- =_aaaaaaaaaa0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers ------- =_aaaaaaaaaa0--