Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal) - Mailing list pgsql-bugs

From Christopher Browne
Subject Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)
Date
Msg-id CAFNqd5UpMkdukDeX+bG0+jJxg1y_y4j_OL4jUm-u+6PAGB7Nbw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)  (Bruce Momjian <bruce@momjian.us>)
Responses Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)
List pgsql-bugs
On 9 December 2014 at 15:56, Bruce Momjian <bruce@momjian.us> wrote:

> On Tue, Dec  9, 2014 at 03:53:52PM -0500, Christopher Browne wrote:
> > > Based on your report, I think checking for INSIDE_EMACS being set _and_
> > > TERM=dumb would be the best bet.  Do you want me to write a patch for
> > > you to test?
> >
> >
> > I'd be really inclined to search INSIDE_EMACS for "comint", as well.
> >
> > That indicates that the comint mode is being used.  <
> http://www.emacswiki.org/
> > emacs/ComintMode>
> >
> > That should indicate a scenario where pager should be suppressed.
> TERM=dumb
> > would tend to agree with that; I'm not sure it is helpful to involve
> $TERM in
> > the logic.
>
> I don't understand.  Is COMINT an environment variable name?  I don't see
> it in INSIDE_EMACS:
>
>         TERM=term-color
>         INSIDE_EMACS=24.4.1,term:0.96
>

In that case, you're running a shell in a buffer that is emulating a
terminal
(a not-dumb one), and I think you'll find that more, less, and most will
work fine
as pagers just as they would in an xterm.

I duplicate that by running M-x term.

I shouldn't think you'd be getting complaints from psql about the terminal
not being "fully functional" in your case.  (I don't, running things in M-x
term)

Your case is, in effect, one where it would be fine for psql to NOT suppress
the pager.  It's a perfectly good test case, but it's not the one that the
original poster was concerned about.

Try M-x shell; when I do so, I get...

$ echo $TERM
dumb
$ echo $INSIDE_EMACS
24.3.1,comint

And "psql -l" kind of blows up on me, as was the point of the thread...

$ psql -l
Line style (linestyle) is ascii.
WARNING: terminal is not fully functional
-  (press RETURN)
[If I press return, I get a list of databases]
[Then, I get...]
(END)

And to get out of (END), I need to type "q", which gets captured by the dumb
terminal.

M-x term provides a shell with rather different behaviour.

It's a good idea to test the patch against both ways of running psql to make
sure things "play well" both ways.
--
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)
Next
From: Tom Lane
Date:
Subject: Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)