Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)

From: Christopher Browne <cbbrowne(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Ed Avis <eda(at)waniasset(dot)com>, PostgreSQL Mailing Lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)
Date: 2014-12-09 20:53:52
Message-ID: CAFNqd5UCy_vw24iWmj4Maycw7UKxjQwamwWTW66xkuwxswWzrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 9 December 2014 at 15:24, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
> On Mon, Dec 8, 2014 at 11:39:12AM +0000, Ed Avis wrote:
> > Tom Lane <tgl <at> sss.pgh.pa.us> writes:
> >
> > >A quick check here shows a couple of different possibilities in the
> > >environment seen in a shell buffer:
> > >
> > >EMACS=t
> > >INSIDE_EMACS=23.1.1,comint
> >
> > Apparently EMACS=t is deprecated and INSIDE_EMACS is the one to use.
> > However, Emacs being Emacs, it has more than one way to run interactive
> > subprocesses. This bug report was about 'shell' mode, where a text
editing
> > buffer provides a simple dumb terminal without cursor movement escape
> > sequences (and sets TERM=dumb). But there is also 'term', providing a
> > reasonably good terminal emulator inside Emacs. Inside that, a pager
does
> > work (even sophisticated ones such as 'less') and it makes sense to use
a
> > pager since you don't have a scrollable text buffer with all output, but
> > just a fixed-size terminal window.
> >
> > 'term' mode sets the environment variables to something like
> >
> > TERM=eterm-color
> > INSIDE_EMACS=24.4.1,term:0.96
> >
> > So if INSIDE_EMACS is to be used (rather than checking for TERM=dumb)
then
> > perhaps it should look for the 'comint' string.
> >
> > I appreciate the concern that this could open a Pandora's box of special
> > case checks for all sorts of terminal types, but this is only the psql
> > interactive shell we are talking about here, not the core database code.
> > And all that is being controlled is the relatively minor choice of
whether
> > to run a pager program, not anything that affects database operations.
> > psql already contains lots of features which exist to make interactive
use
> > more comfortable even at the expense of some complexity.
>
> 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.

--
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2014-12-09 20:56:12 Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)
Previous Message Bruce Momjian 2014-12-09 20:24:06 Re: BUG #11986: psql uses pager inside Emacs shell buffer (not a terminal)