From owner-svn-src-head@freebsd.org Sun Jun 3 21:00:01 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 484BCFD4F7C; Sun, 3 Jun 2018 21:00:01 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EA9D77C1DD; Sun, 3 Jun 2018 21:00:00 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C930A23C35; Sun, 3 Jun 2018 21:00:00 +0000 (UTC) (envelope-from pstef@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w53L00OY020252; Sun, 3 Jun 2018 21:00:00 GMT (envelope-from pstef@FreeBSD.org) Received: (from pstef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w53KxxUK020187; Sun, 3 Jun 2018 20:59:59 GMT (envelope-from pstef@FreeBSD.org) Message-Id: <201806032059.w53KxxUK020187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pstef set sender to pstef@FreeBSD.org using -f From: Piotr Pawel Stefaniak Date: Sun, 3 Jun 2018 20:59:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334588 - head/usr.bin/indent X-SVN-Group: head X-SVN-Commit-Author: pstef X-SVN-Commit-Paths: head/usr.bin/indent X-SVN-Commit-Revision: 334588 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2018 21:00:01 -0000 Author: pstef Date: Sun Jun 3 20:59:59 2018 New Revision: 334588 URL: https://svnweb.freebsd.org/changeset/base/334588 Log: indent(1): new option -lpl (always line up to parenthesis) With -lp, if a line has an opening paren which is not closed on that line, then continuation lines will be lined up to start at the character position just after the opening paren. Submitted by: Tom Lane Modified: head/usr.bin/indent/args.c head/usr.bin/indent/indent.1 head/usr.bin/indent/indent.c head/usr.bin/indent/indent_globs.h head/usr.bin/indent/io.c Modified: head/usr.bin/indent/args.c ============================================================================== --- head/usr.bin/indent/args.c Sun Jun 3 20:48:58 2018 (r334587) +++ head/usr.bin/indent/args.c Sun Jun 3 20:59:59 2018 (r334588) @@ -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_compilation}, @@ -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}, Modified: head/usr.bin/indent/indent.1 ============================================================================== --- head/usr.bin/indent/indent.1 Sun Jun 3 20:48:58 2018 (r334587) +++ head/usr.bin/indent/indent.1 Sun Jun 3 20:59:59 2018 (r334588) @@ -73,6 +73,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 @@ -355,7 +356,9 @@ The default is for local variable names to be indented by the same amount as global ones. .It Fl \&lp , nlp Lines up code surrounded by parentheses in continuation lines. -If a line +With +.Fl \&lp , +if a line has a left paren which is not closed on that line, then continuation lines will be lined up to start at the character position just after the left paren. @@ -382,6 +385,19 @@ p1\ =\ first_procedure(second_procedure(p2, \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 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 Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Sun Jun 3 20:48:58 2018 (r334587) +++ head/usr.bin/indent/indent.c Sun Jun 3 20:59:59 2018 (r334588) @@ -174,6 +174,7 @@ main(int argc, char **argv) #ifdef undef max_col = 78; /* -l78 */ lineup_to_parens = 1; /* -lp */ + lineup_to_parens_always = 0; /* -nlpl */ ps.ljust_decl = 0; /* -ndj */ ps.com_ind = 33; /* -c33 */ star_comment_cont = 1; /* -sc */ Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jun 3 20:48:58 2018 (r334587) +++ head/usr.bin/indent/indent_globs.h Sun Jun 3 20:59:59 2018 (r334588) @@ -186,6 +186,8 @@ int continuation_indent;/* set to the indentat * 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 Modified: head/usr.bin/indent/io.c ============================================================================== --- head/usr.bin/indent/io.c Sun Jun 3 20:48:58 2018 (r334587) +++ head/usr.bin/indent/io.c Sun Jun 3 20:59:59 2018 (r334588) @@ -226,6 +226,8 @@ compute_code_target(void) if (!lineup_to_parens) target_col += continuation_indent * (2 * continuation_indent == ps.ind_size ? 1 : ps.paren_level); + else if (lineup_to_parens_always) + target_col = paren_target; else { int w; int t = paren_target;