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
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.