Re: [HACKERS] pgindent wishlist item

2014-01-31 Thread Bruce Momjian
On Fri, Jan 31, 2014 at 07:15:05PM +0100, Andres Freund wrote:
> On 2014-01-31 12:29:52 -0500, Andrew Dunstan wrote:
> > While Bruce is working on pgindent
> 
> If it's christmas, let me wish for a not completly broken formatting of
> function typedefs. E.g.
> typedef ForeignScan *(*GetForeignPlan_function) (PlannerInfo *root,
>  RelOptInfo *baserel,
>   Oid foreigntableid,
>   ForeignPath *best_path,
>  List *tlist,
>  List *scan_clauses);
> is ridiculous. It can't be convinced to add a newline at any helpful
> place afaik.

Uh, not sure how to help here.  :-(

-- 
  Bruce Momjian  http://momjian.us
  EnterpriseDB http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pgindent wishlist item

2014-01-31 Thread Bruce Momjian
On Fri, Jan 31, 2014 at 12:44:22PM -0500, Tom Lane wrote:
> Andrew Dunstan  writes:
> > While Bruce is working on pgindent, let me register a small wishlist 
> > item. It would be quite useful to be able to supply extra typedefs on 
> > the command line to supplement a typedefs file downloaded from the 
> > buildfarm or constructed however. A concrete example: in the code I have 
> > been recently working on, there are typedefs for Jsonb and JsonbValue. 
> > If I run pgindent as normal on the new code these items are not treated 
> > properly. What I had to do was take a special copy of the typedefs list 
> > and add those two items. If we could pass a list of extra typedefs to 
> > supplement the typedefs file that would be very useful. Then I could do 
> > something like:
> 
> > pgindent --typedef Jsonb --typedef JsonbValue
> > src/backend/utils/adt/jsonfuncs.c
> 
> > without having to mangle a typedefs file.
> 
> Personally, I always just edit the downloaded file to add whatever
> typedefs the patch I'm working on adds.  I wouldn't use a command
> line switch even if there was one, because then I'd have to remember
> which typedef names to add each time I run pgindent.

Easily added, so done with the attached, applied patch.  You use it
like this:

pgindent --list-of-typedefs 'abc def'

-- 
  Bruce Momjian  http://momjian.us
  EnterpriseDB http://enterprisedb.com

  + Everyone has their own god. +
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
new file mode 100755
index 8e45b18..2de7a53
*** a/src/tools/pgindent/pgindent
--- b/src/tools/pgindent/pgindent
*** my $indent_opts =
*** 22,31 
  # indent-dependant settings
  my $extra_opts = "";
  
! my ($typedefs_file, $code_base, $excludes, $indent, $build);
  
  my %options = (
  	"typedefs=s"  => \$typedefs_file,
  	"code-base=s" => \$code_base,
  	"excludes=s"  => \$excludes,
  	"indent=s"=> \$indent,
--- 22,32 
  # indent-dependant settings
  my $extra_opts = "";
  
! my ($typedefs_file, $typedef_str, $code_base, $excludes, $indent, $build);
  
  my %options = (
  	"typedefs=s"  => \$typedefs_file,
+ 	"list-of-typedefs=s"  => \$typedef_str,
  	"code-base=s" => \$code_base,
  	"excludes=s"  => \$excludes,
  	"indent=s"=> \$indent,
*** sub load_typedefs
*** 125,130 
--- 126,138 
  	  || die "cannot open typedefs file \"$typedefs_file\": $!\n";
  	my @typedefs = <$typedefs_fh>;
  	close($typedefs_fh);
+ 	if (defined($typedef_str))
+ 	{
+ 		foreach my $typedef (split(m/[, \t\n]+/, $typedef_str))
+ 		{
+ 			push(@typedefs, $typedef . "\n");
+ 		}
+ 	}
  
  	# remove certain entries
  	@typedefs =

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pgindent wishlist item

2014-01-31 Thread Andres Freund
On 2014-01-31 12:29:52 -0500, Andrew Dunstan wrote:
> While Bruce is working on pgindent

If it's christmas, let me wish for a not completly broken formatting of
function typedefs. E.g.
typedef ForeignScan *(*GetForeignPlan_function) (PlannerInfo *root,
 RelOptInfo *baserel,
  Oid foreigntableid,
  ForeignPath *best_path,
 List *tlist,
 List *scan_clauses);
is ridiculous. It can't be convinced to add a newline at any helpful
place afaik.


Greetings,

Andres Freund

-- 
 Andres Freund http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pgindent wishlist item

2014-01-31 Thread Tom Lane
Andrew Dunstan  writes:
> While Bruce is working on pgindent, let me register a small wishlist 
> item. It would be quite useful to be able to supply extra typedefs on 
> the command line to supplement a typedefs file downloaded from the 
> buildfarm or constructed however. A concrete example: in the code I have 
> been recently working on, there are typedefs for Jsonb and JsonbValue. 
> If I run pgindent as normal on the new code these items are not treated 
> properly. What I had to do was take a special copy of the typedefs list 
> and add those two items. If we could pass a list of extra typedefs to 
> supplement the typedefs file that would be very useful. Then I could do 
> something like:

> pgindent --typedef Jsonb --typedef JsonbValue
> src/backend/utils/adt/jsonfuncs.c

> without having to mangle a typedefs file.

Personally, I always just edit the downloaded file to add whatever
typedefs the patch I'm working on adds.  I wouldn't use a command
line switch even if there was one, because then I'd have to remember
which typedef names to add each time I run pgindent.

regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] pgindent wishlist item

2014-01-31 Thread Andrew Dunstan


While Bruce is working on pgindent, let me register a small wishlist 
item. It would be quite useful to be able to supply extra typedefs on 
the command line to supplement a typedefs file downloaded from the 
buildfarm or constructed however. A concrete example: in the code I have 
been recently working on, there are typedefs for Jsonb and JsonbValue. 
If I run pgindent as normal on the new code these items are not treated 
properly. What I had to do was take a special copy of the typedefs list 
and add those two items. If we could pass a list of extra typedefs to 
supplement the typedefs file that would be very useful. Then I could do 
something like:


   pgindent --typedef Jsonb --typedef JsonbValue
   src/backend/utils/adt/jsonfuncs.c

without having to mangle a typedefs file.

This would make using pgindent nicer to use during development, since 
any significant development is just about guaranteed to have some new 
typedefs the buildfarm can't have.


cheers

andrew


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers