Re: [HACKERS] proposal: psql: check env variable PSQL_PAGER

2017-09-13 Thread Pavel Stehule
2017-09-13 23:36 GMT+02:00 Thomas Munro :

> On Wed, Sep 6, 2017 at 4:12 AM, Pavel Stehule 
> wrote:
> > 2017-09-05 18:06 GMT+02:00 Tom Lane :
> >> Pushed, with some fooling with the documentation (notably,
> >> re-alphabetizing relevant lists).
> >>
> > Thank you very much
>
> I've started setting PSQL_PAGER="~/bin/pspg -s0" to try your new
> column-aware pager from https://github.com/okbob/pspg for my regular
> work.  Wow!  It could use some warning clean-up but it's a clever idea
> and so far it works really well.  Thanks for making this.
>

:) Thank you. It is really fresh project - I started it three months ago,
so probably there are lot of issues. It is +/- little bit cleaned and
enhanced prototype. But I hope - it is used together with psql very well.

Yesterday I cleaned all warnings and I prepared autoconf and rpmbuild. I
have a plan to release it next week.

Regards

Pavel


> --
> Thomas Munro
> http://www.enterprisedb.com
>


Re: [HACKERS] proposal: psql: check env variable PSQL_PAGER

2017-09-13 Thread Thomas Munro
On Wed, Sep 6, 2017 at 4:12 AM, Pavel Stehule  wrote:
> 2017-09-05 18:06 GMT+02:00 Tom Lane :
>> Pushed, with some fooling with the documentation (notably,
>> re-alphabetizing relevant lists).
>>
> Thank you very much

I've started setting PSQL_PAGER="~/bin/pspg -s0" to try your new
column-aware pager from https://github.com/okbob/pspg for my regular
work.  Wow!  It could use some warning clean-up but it's a clever idea
and so far it works really well.  Thanks for making this.

-- 
Thomas Munro
http://www.enterprisedb.com


-- 
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] proposal: psql: check env variable PSQL_PAGER

2017-09-05 Thread Pavel Stehule
2017-09-05 18:06 GMT+02:00 Tom Lane :

> Pavel Stehule  writes:
> > [ psql-psql-pager-env-2.patch ]
>
> Pushed, with some fooling with the documentation (notably,
> re-alphabetizing relevant lists).
>
> Grepping turned up an additional place that's examining the PAGER
> environment variable, namely PQprint() in libpq/fe-print.c.  That's
> not used by psql (or anything else in core PG) anymore; we're only
> keeping it around for hypothetical external users of libpq.  I debated
> whether to make it honor PSQL_PAGER.  I decided not to, since those
> external users are by definition not psql ... but I added
> a comment about that.
>

Thank you very much

Pavel


>
> regards, tom lane
>


Re: [HACKERS] proposal: psql: check env variable PSQL_PAGER

2017-09-05 Thread Tom Lane
Pavel Stehule  writes:
> [ psql-psql-pager-env-2.patch ]

Pushed, with some fooling with the documentation (notably,
re-alphabetizing relevant lists).

Grepping turned up an additional place that's examining the PAGER
environment variable, namely PQprint() in libpq/fe-print.c.  That's
not used by psql (or anything else in core PG) anymore; we're only
keeping it around for hypothetical external users of libpq.  I debated
whether to make it honor PSQL_PAGER.  I decided not to, since those
external users are by definition not psql ... but I added
a comment about that.

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


Re: [HACKERS] proposal: psql: check env variable PSQL_PAGER

2017-08-16 Thread Pavel Stehule
2017-08-16 12:47 GMT+02:00 Thomas Munro :

> On Wed, Aug 16, 2017 at 9:56 PM, Pavel Stehule 
> wrote:
> > 2017-08-16 6:58 GMT+02:00 Thomas Munro :
> >> Stray blank line.
> >
> > I am not sure if I see last issue well.
>
> I meant this:
>
>   
> +
>  
>
> ... but it doesn't really matter.
>
> >  Sending updated patch
>
> Thanks, looks good.  New status: ready for committer.
>

Thank you

Pavel


>
> --
> Thomas Munro
> http://www.enterprisedb.com
>


Re: [HACKERS] proposal: psql: check env variable PSQL_PAGER

2017-08-16 Thread Thomas Munro
On Wed, Aug 16, 2017 at 9:56 PM, Pavel Stehule  wrote:
> 2017-08-16 6:58 GMT+02:00 Thomas Munro :
>> Stray blank line.
>
> I am not sure if I see last issue well.

I meant this:

  
+
 

... but it doesn't really matter.

>  Sending updated patch

Thanks, looks good.  New status: ready for committer.

-- 
Thomas Munro
http://www.enterprisedb.com


-- 
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] proposal: psql: check env variable PSQL_PAGER

2017-08-16 Thread Pavel Stehule
Hi

2017-08-16 6:58 GMT+02:00 Thomas Munro :

> On Thu, Jul 27, 2017 at 4:19 AM, Pavel Stehule 
> wrote:
> > here is a patch - it is trivial
>
> The feature makes sense, follows an existing example (PSQL_EDITOR),
> and works nicely.
>
>is platform-dependent.  Use of the pager can be disabled by setting
>PAGER to empty, or by using pager-related options of
>
> Maybe this should now say "... can be disabled by specifying an empty
> string", since "... by setting PAGER to empty" isn't quite the full
> story.
>
> -  the \pset command.
> +  the \pset command. These variables are examined
> +  in the order listed; the first that is set is used.
>   
> +
>
> Stray blank line.
>

I am not sure if I see last issue well. Sending updated patch

Regards

Pavel


>
> --
> Thomas Munro
> http://www.enterprisedb.com
>
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index c592edac60..fbce45b90e 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -4087,17 +4087,20 @@ $endif

 

+PSQL_PAGER
 PAGER
 
 
  
   If the query results do not fit on the screen, they are piped
-  through this command.  Typical values are
-  more or less.  The default
-  is platform-dependent.  Use of the pager can be disabled by setting
-  PAGER to empty, or by using pager-related options of
-  the \pset command.
+  through this command. Typical values are more
+  or less. The default is platform-dependent.
+  Use of the pager can be disabled by setting PSQL_PAGER
+  or PAGER to empty string, or by using pager-related
+  options of the \pset command. These variables
+  are examined in the order listed; the first that is set is used.
  
+
 

 
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index b3dbb5946e..9b0b83b0bd 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -411,7 +411,7 @@ helpVariables(unsigned short int pager)
 #endif
 
 	fprintf(output, _("  COLUMNSnumber of columns for wrapped format\n"));
-	fprintf(output, _("  PAGER  name of external pager program\n"));
+	fprintf(output, _("  PSQL_PAGER, PAGER  name of external pager program\n"));
 	fprintf(output, _("  PGAPPNAME  same as the application_name connection parameter\n"));
 	fprintf(output, _("  PGDATABASE same as the dbname connection parameter\n"));
 	fprintf(output, _("  PGHOST same as the host connection parameter\n"));
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index f756f767e5..8af5bbe97e 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -2870,7 +2870,9 @@ PageOutput(int lines, const printTableOpt *topt)
 			const char *pagerprog;
 			FILE	   *pagerpipe;
 
-			pagerprog = getenv("PAGER");
+			pagerprog = getenv("PSQL_PAGER");
+			if (!pagerprog)
+pagerprog = getenv("PAGER");
 			if (!pagerprog)
 pagerprog = DEFAULT_PAGER;
 			else

-- 
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] proposal: psql: check env variable PSQL_PAGER

2017-08-15 Thread Thomas Munro
On Thu, Jul 27, 2017 at 4:19 AM, Pavel Stehule  wrote:
> here is a patch - it is trivial

The feature makes sense, follows an existing example (PSQL_EDITOR),
and works nicely.

   is platform-dependent.  Use of the pager can be disabled by setting
   PAGER to empty, or by using pager-related options of

Maybe this should now say "... can be disabled by specifying an empty
string", since "... by setting PAGER to empty" isn't quite the full
story.

-  the \pset command.
+  the \pset command. These variables are examined
+  in the order listed; the first that is set is used.
  
+

Stray blank line.

-- 
Thomas Munro
http://www.enterprisedb.com


-- 
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] proposal: psql: check env variable PSQL_PAGER

2017-07-26 Thread Pavel Stehule
Hi

2017-07-26 13:15 GMT+02:00 Dagfinn Ilmari Mannsåker :

> Pavel Stehule  writes:
>
> > Hi
> >
> > I wrote a special pager for psql. Surely, this pager is not good for
> paging
> > of man pages. So is not good to set it as global pager. We can introduce
> > new env variable PSQL_PAGER for this purpose. It can work similar like
> > PSQL_EDITOR variable.
> >
> > Notes, comments?
>
> There's already the option to put '\setenv PAGER ...' in .psqlrc, but I
> guess having it work like EDITOR makes sense for consistency, as well as
> not affecting commands spawned from psql via e.g. \!.
>

here is a patch - it is trivial

Regards

Pavel

>
> - ilmari
> --
> "The surreality of the universe tends towards a maximum" -- Skud's Law
> "Never formulate a law or axiom that you're not prepared to live with
>  the consequences of."  -- Skud's Meta-Law
>
commit cc5aac7ab431dd0a95062aa5171f860215d5bc4a
Author: Pavel Stehule 
Date:   Wed Jul 26 18:12:26 2017 +0200

initial

diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index c592edac60..ef89f81fdf 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -4087,6 +4087,7 @@ $endif

 

+PSQL_PAGER
 PAGER
 
 
@@ -4096,8 +4097,10 @@ $endif
   more or less.  The default
   is platform-dependent.  Use of the pager can be disabled by setting
   PAGER to empty, or by using pager-related options of
-  the \pset command.
+  the \pset command. These variables are examined
+  in the order listed; the first that is set is used.
  
+
 

 
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index b3dbb5946e..9b0b83b0bd 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -411,7 +411,7 @@ helpVariables(unsigned short int pager)
 #endif
 
 	fprintf(output, _("  COLUMNSnumber of columns for wrapped format\n"));
-	fprintf(output, _("  PAGER  name of external pager program\n"));
+	fprintf(output, _("  PSQL_PAGER, PAGER  name of external pager program\n"));
 	fprintf(output, _("  PGAPPNAME  same as the application_name connection parameter\n"));
 	fprintf(output, _("  PGDATABASE same as the dbname connection parameter\n"));
 	fprintf(output, _("  PGHOST same as the host connection parameter\n"));
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index f756f767e5..8af5bbe97e 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -2870,7 +2870,9 @@ PageOutput(int lines, const printTableOpt *topt)
 			const char *pagerprog;
 			FILE	   *pagerpipe;
 
-			pagerprog = getenv("PAGER");
+			pagerprog = getenv("PSQL_PAGER");
+			if (!pagerprog)
+pagerprog = getenv("PAGER");
 			if (!pagerprog)
 pagerprog = DEFAULT_PAGER;
 			else

-- 
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] proposal: psql: check env variable PSQL_PAGER

2017-07-26 Thread Dagfinn Ilmari Mannsåker
Pavel Stehule  writes:

> Hi
>
> I wrote a special pager for psql. Surely, this pager is not good for paging
> of man pages. So is not good to set it as global pager. We can introduce
> new env variable PSQL_PAGER for this purpose. It can work similar like
> PSQL_EDITOR variable.
>
> Notes, comments?

There's already the option to put '\setenv PAGER ...' in .psqlrc, but I
guess having it work like EDITOR makes sense for consistency, as well as
not affecting commands spawned from psql via e.g. \!.

- ilmari
-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."  -- Skud's Meta-Law


-- 
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] proposal: psql: check env variable PSQL_PAGER

2017-07-26 Thread Julien Rouhaud
On Wed, Jul 26, 2017 at 7:11 AM, Pavel Stehule  wrote:
> Hi
>
> I wrote a special pager for psql. Surely, this pager is not good for paging
> of man pages. So is not good to set it as global pager. We can introduce new
> env variable PSQL_PAGER for this purpose. It can work similar like
> PSQL_EDITOR variable.
>

+1.  I used to have a psql alias just for this, so it'd definitely be useful.


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


[HACKERS] proposal: psql: check env variable PSQL_PAGER

2017-07-25 Thread Pavel Stehule
Hi

I wrote a special pager for psql. Surely, this pager is not good for paging
of man pages. So is not good to set it as global pager. We can introduce
new env variable PSQL_PAGER for this purpose. It can work similar like
PSQL_EDITOR variable.

Notes, comments?

Regards

Pavel