unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26654: 26.0.50; Request to add an option to make emacs not care if input is not coming from tty
@ 2017-04-25 14:22 Kaushal Modi
  2017-04-26 10:12 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Kaushal Modi @ 2017-04-25 14:22 UTC (permalink / raw)
  To: 26654

[-- Attachment #1: Type: text/plain, Size: 872 bytes --]

Hello,

I have a bash script eless ( https://github.com/kaushalmodi/eless ) that I
would like to use to replace 'less' use cases.

I would like to do something like:

    echo "foo" | emacs -Q -nw

If I try to do that at the moment, I get

    emacs: standard input is not a tty

So this is a feature request to make emacs ignore if standard input is
coming in through another process and not tty. The eless script saves the
input from pipe to a temp file and opens that in "emacs -Q -nw" by default.
So emacs does not need addition of a feature to read directly from STDIN
(as the bash wrapper does it for me).

I have noticed that emacsclient does not care if input is not coming from
tty. So this bug report is to request emacs to behave the same way.

I am calling this a feature request because I see this behavior at least
from emacs 24.3 onwards.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1265 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#26654: 26.0.50; Request to add an option to make emacs not care if input is not coming from tty
  2017-04-25 14:22 bug#26654: 26.0.50; Request to add an option to make emacs not care if input is not coming from tty Kaushal Modi
@ 2017-04-26 10:12 ` Eli Zaretskii
  2017-04-26 17:08   ` Kaushal Modi
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2017-04-26 10:12 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: 26654

> From: Kaushal Modi <kaushal.modi@gmail.com>
> Date: Tue, 25 Apr 2017 14:22:55 +0000
> 
> I have a bash script eless ( https://github.com/kaushalmodi/eless ) that I would like to use to replace 'less' use
> cases.
> 
> I would like to do something like:
> 
> echo "foo" | emacs -Q -nw
> 
> If I try to do that at the moment, I get
> 
> emacs: standard input is not a tty
> 
> So this is a feature request to make emacs ignore if standard input is coming in through another process and
> not tty. The eless script saves the input from pipe to a temp file and opens that in "emacs -Q -nw" by default.
> So emacs does not need addition of a feature to read directly from STDIN (as the bash wrapper does it for
> me).

Then why not do something like below instead?

  echo "foo" && emacs -Q -nw

IOW, I don't understand what is the significance of the pipe in this
command.

> I have noticed that emacsclient does not care if input is not coming from tty.

The client doesn't interact with the user, it only instructs the
server to visit the file.  Emacs, OTOH, does need to interact.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#26654: 26.0.50; Request to add an option to make emacs not care if input is not coming from tty
  2017-04-26 10:12 ` Eli Zaretskii
@ 2017-04-26 17:08   ` Kaushal Modi
  0 siblings, 0 replies; 3+ messages in thread
From: Kaushal Modi @ 2017-04-26 17:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 26654

[-- Attachment #1: Type: text/plain, Size: 2338 bytes --]

On Wed, Apr 26, 2017 at 6:13 AM Eli Zaretskii <eliz@gnu.org> wrote:

>
> Then why not do something like below instead?
>
>   echo "foo" && emacs -Q -nw
>

Well, my example was too simplified; I do care that "foo" gets into the
emacs buffer, just not "how". At the moment emacs does not accept input
from STDIN in non-batch mode. So I use a wrapper script (
https://raw.githubusercontent.com/kaushalmodi/eless/master/eless ) to save
the STDIN into a temp file and then open that temp file in emacs.


> IOW, I don't understand what is the significance of the pipe in this
> command.
>

The "man grep" is the best example.. I cannot control how man calls the
$PAGER. If I set $PAGER as eless, man eventually does something like "blah
blah | $PAGER".

The common use cases for eless are as follows:

    eless foo.txt                  # Open foo.txt in eless in terminal
(-nw) mode by default.
    eless foo.txt -gui             # Open foo.txt in eless in GUI mode.
    echo 'foo' | eless             #
    echo 'foo' | eless -           # Same as above. The hyphen after eless
does not matter; is anyways discarded.
    grep 'bar' foo.txt | eless     #
    PAGER=eless man grep           # Launches man pages in eless (terminal
mode), if the environment variable PAGER is set to eless.
    PAGER=eless man grep -gui      # Launches man pages in eless (GUI
mode), if the environment variable PAGER is set to eless.
    diff foo bar | eless           # Colored diff!
    eless .                        # Open dired in the current directory
(enhanced 'ls')
    eless -h | eless               # See eless help ;-)

> I have noticed that emacsclient does not care if input is not coming from
> tty.
>
> The client doesn't interact with the user, it only instructs the
> server to visit the file.  Emacs, OTOH, does need to interact.
>

That's alright, at the minimum it would be nice to have emacs not error out
if it detects input coming from STDIN.. it does not have to worry, the bash
script will take care of that (The best case if ofcourse if emacs can read
in STDIN in non-batch mode too).

For now, we use a workaround in eless that always starts emacs in a new
sub-shell and that way the sub-shelled emacs always "thinks" that it not
receiving anything from the stdin. But would like to get away from this
limitation.

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 3514 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-26 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-25 14:22 bug#26654: 26.0.50; Request to add an option to make emacs not care if input is not coming from tty Kaushal Modi
2017-04-26 10:12 ` Eli Zaretskii
2017-04-26 17:08   ` Kaushal Modi

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).