all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* redirect stdout to emacs scratch
@ 2008-12-08  8:55 pagod
  0 siblings, 0 replies; 7+ messages in thread
From: pagod @ 2008-12-08  8:55 UTC (permalink / raw)
  To: Help-gnu-emacs


hi everyone!

this is probably a very easy question (there has to be a way!), but i
haven't been able to find the answer, so i'm turning to this forum, hoping
someone can give me a hint!

what i want to do is very simple: i want to be able to redirect the stdout
of any program on the command line into emacs' scratch buffer -- the way it
works with less or joe or whatever. i want to do it with emacs because i'm
used to using it and i need syntax coloring, but when i try it i get the
message "standard input is not a tty". then what is it? the way i've tried
it is quite the usual way:

pagod> echo "hello, world" | emacs
emacs: standard input is not a tty

my emacs is aliased to "emacs -nw" because i'm in a terminal, so the option
is assumed by default anyway. i'm using the no-window version of emacs
because i run it from within an ssh session running zsh on a linux server,
connecting using putty from a windows workstation. emacs version is 22.2.1,
running in a SuSE 11.0.

it'd be great if someone could help me do that!

thx a lot

David

-- 
View this message in context: http://www.nabble.com/redirect-stdout-to-emacs-scratch-tp20890718p20890718.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

* Re: redirect stdout to emacs scratch
       [not found] <mailman.2220.1228741417.26697.help-gnu-emacs@gnu.org>
@ 2008-12-08 15:22 ` Chetan
  2008-12-08 15:43   ` Teemu Likonen
  2008-12-08 19:09   ` Chetan
  0 siblings, 2 replies; 7+ messages in thread
From: Chetan @ 2008-12-08 15:22 UTC (permalink / raw)
  To: help-gnu-emacs

pagod <dvergnaud@yahoo.com> writes:

> hi everyone!
>
> this is probably a very easy question (there has to be a way!), but i
> haven't been able to find the answer, so i'm turning to this forum, hoping
> someone can give me a hint!
>
> what i want to do is very simple: i want to be able to redirect the stdout
> of any program on the command line into emacs' scratch buffer -- the way it
> works with less or joe or whatever. i want to do it with emacs because i'm
> used to using it and i need syntax coloring, but when i try it i get the
> message "standard input is not a tty". then what is it? the way i've tried
> it is quite the usual way:
>
> pagod> echo "hello, world" | emacs
> emacs: standard input is not a tty
>
> my emacs is aliased to "emacs -nw" because i'm in a terminal, so the option
> is assumed by default anyway. i'm using the no-window version of emacs
> because i run it from within an ssh session running zsh on a linux server,
> connecting using putty from a windows workstation. emacs version is 22.2.1,
> running in a SuSE 11.0.
>
> it'd be great if someone could help me do that!
>
> thx a lot
>
> David

Do you really need to do it this way? You can run it quite simply
within the eshell prompt inside emacs.
M-x eshell
eshell$ echo "foo" >> #<buffer *scratch*>
eshell$ myprog >> #<buffer *scratch*>
echell$ echo "bar" >> #<buffer *scratch*>


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

* Re: redirect stdout to emacs scratch
  2008-12-08 15:22 ` Chetan
@ 2008-12-08 15:43   ` Teemu Likonen
  2008-12-08 19:30     ` harven
  2008-12-08 19:09   ` Chetan
  1 sibling, 1 reply; 7+ messages in thread
From: Teemu Likonen @ 2008-12-08 15:43 UTC (permalink / raw)
  To: help-gnu-emacs

Chetan (2008-12-08 07:22 -0800) wrote:

> pagod <dvergnaud@yahoo.com> writes:
>> pagod> echo "hello, world" | emacs

I believe there is not any nice way to do this.

> You can run it quite simply within the eshell prompt inside emacs.
> M-x eshell
> eshell$ echo "foo" >> #<buffer *scratch*>
> eshell$ myprog >> #<buffer *scratch*>
> echell$ echo "bar" >> #<buffer *scratch*>

Another and perhaps more obvious solution is to run shell commands with
M-1 M-! command while in the *scratch* buffer. For example:

    M-1 M-! echo "foo"

It can actually be any prefix argument for M-!, not just number 1, but
M-1 is a good choice when ! is in the same key as 1.


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

* Re: redirect stdout to emacs scratch
  2008-12-08 15:22 ` Chetan
  2008-12-08 15:43   ` Teemu Likonen
@ 2008-12-08 19:09   ` Chetan
  1 sibling, 0 replies; 7+ messages in thread
From: Chetan @ 2008-12-08 19:09 UTC (permalink / raw)
  To: help-gnu-emacs

Chetan <Chetan.xspam@xspam.sbcglobal.net> writes:

> pagod <dvergnaud@yahoo.com> writes:
>
>> hi everyone!
>>
>> this is probably a very easy question (there has to be a way!), but i
>> haven't been able to find the answer, so i'm turning to this forum, hoping
>> someone can give me a hint!
>>
>> what i want to do is very simple: i want to be able to redirect the stdout
>> of any program on the command line into emacs' scratch buffer -- the way it
>> works with less or joe or whatever. i want to do it with emacs because i'm
>> used to using it and i need syntax coloring, but when i try it i get the
>> message "standard input is not a tty". then what is it? the way i've tried
>> it is quite the usual way:
>>
>> pagod> echo "hello, world" | emacs
>> emacs: standard input is not a tty
>>
>> my emacs is aliased to "emacs -nw" because i'm in a terminal, so the option
>> is assumed by default anyway. i'm using the no-window version of emacs
>> because i run it from within an ssh session running zsh on a linux server,
>> connecting using putty from a windows workstation. emacs version is 22.2.1,
>> running in a SuSE 11.0.
>>
>> it'd be great if someone could help me do that!
>>
>> thx a lot
>>
>> David
>
> Do you really need to do it this way? You can run it quite simply
> within the eshell prompt inside emacs.
> M-x eshell
> eshell$ echo "foo" >> #<buffer *scratch*>
> eshell$ myprog >> #<buffer *scratch*>
> echell$ echo "bar" >> #<buffer *scratch*>

I forgot to mention that you could use echo -n foo to get the output
terminated with a newline.

With eshell, commands written with elisp are used where possible, so
you may be able to do something that is not possible using external
commands alone. I use W32 and these commands work even if there are no
external executables available.




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

* Re: redirect stdout to emacs scratch
  2008-12-08 15:43   ` Teemu Likonen
@ 2008-12-08 19:30     ` harven
  0 siblings, 0 replies; 7+ messages in thread
From: harven @ 2008-12-08 19:30 UTC (permalink / raw)
  To: help-gnu-emacs

Teemu Likonen <tlikonen@iki.fi> writes:

> Chetan (2008-12-08 07:22 -0800) wrote:
>
>> pagod <dvergnaud@yahoo.com> writes:
>>> pagod> echo "hello, world" | emacs
>
> I believe there is not any nice way to do this.
>
>> You can run it quite simply within the eshell prompt inside emacs.
>> M-x eshell
>> eshell$ echo "foo" >> #<buffer *scratch*>
>> eshell$ myprog >> #<buffer *scratch*>
>> echell$ echo "bar" >> #<buffer *scratch*>
>
> Another and perhaps more obvious solution is to run shell commands with
> M-1 M-! command while in the *scratch* buffer. For example:
>
>     M-1 M-! echo "foo"
>
> It can actually be any prefix argument for M-!, not just number 1, but
> M-1 is a good choice when ! is in the same key as 1.

As a workaround you can also try the following:

   C-x C-f .scratch
   M-x lisp-interaction-mode
   M-x auto-revert-tail-mode

You get some sort of new scratch buffer called ".scratch". Then you can add
from the command line to this new scratch buffer with:

   echo "my text" >> .scratch

The text should appear in this new scratch buffer within seconds.



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

* Re: redirect stdout to emacs scratch
       [not found] <mailman.2219.1228741415.26697.help-gnu-emacs@gnu.org>
@ 2008-12-09  3:59 ` Andreas Politz
  2008-12-18  9:38 ` harven
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Politz @ 2008-12-09  3:59 UTC (permalink / raw)
  To: help-gnu-emacs

pagod wrote:
> hi everyone!
> 
> this is probably a very easy question (there has to be a way!), but i
> haven't been able to find the answer, so i'm turning to this forum, hoping
> someone can give me a hint!
> 
> what i want to do is very simple: i want to be able to redirect the stdout
> of any program on the command line into emacs' scratch buffer -- the way it
> works with less or joe or whatever. i want to do it with emacs because i'm
> used to using it and i need syntax coloring, but when i try it i get the
> message "standard input is not a tty". then what is it? the way i've tried
> it is quite the usual way:
> 
> pagod> echo "hello, world" | emacs
> emacs: standard input is not a tty

$ tty
/dev/pts/1

$ ls | tty
not a tty

You could pick up the piped input, put it somewhere and make emacs read
it after the pipe finished and input comes again from the terminal.

alias emacs-with-stdin='cat > /tmp/emacs_stdin ; emacs -nw -Q --eval "(insert-file \"/tmp/emacs_stdin\")"'

This works in bash, I don't know about zsh.

-ap
> 
> my emacs is aliased to "emacs -nw" because i'm in a terminal, so the option
> is assumed by default anyway. i'm using the no-window version of emacs
> because i run it from within an ssh session running zsh on a linux server,
> connecting using putty from a windows workstation. emacs version is 22.2.1,
> running in a SuSE 11.0.
> 
> it'd be great if someone could help me do that!
> 
> thx a lot
> 
> David
> 


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

* Re: redirect stdout to emacs scratch
       [not found] <mailman.2219.1228741415.26697.help-gnu-emacs@gnu.org>
  2008-12-09  3:59 ` Andreas Politz
@ 2008-12-18  9:38 ` harven
  1 sibling, 0 replies; 7+ messages in thread
From: harven @ 2008-12-18  9:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Dec 8, 9:55 am, pagod <dvergn...@yahoo.com> wrote:
> hi everyone!
>
> this is probably a very easy question (there has to be a way!), but i
> haven't been able to find the answer, so i'm turning to this forum, hoping
> someone can give me a hint!
>
> what i want to do is very simple: i want to be able to redirect the stdout
> of any program on the command line into emacs' scratch buffer -- the way it
> works with less or joe or whatever. i want to do it with emacs because i'm
> used to using it and i need syntax coloring, but when i try it i get the
> message "standard input is not a tty". then what is it? the way i've tried
> it is quite the usual way:
>
> pagod> echo "hello, world" | emacs
> emacs: standard input is not a tty

the following may help
http://www.shellarchive.co.uk/content/emacs_tips.html#sec15


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

end of thread, other threads:[~2008-12-18  9:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-08  8:55 redirect stdout to emacs scratch pagod
     [not found] <mailman.2220.1228741417.26697.help-gnu-emacs@gnu.org>
2008-12-08 15:22 ` Chetan
2008-12-08 15:43   ` Teemu Likonen
2008-12-08 19:30     ` harven
2008-12-08 19:09   ` Chetan
     [not found] <mailman.2219.1228741415.26697.help-gnu-emacs@gnu.org>
2008-12-09  3:59 ` Andreas Politz
2008-12-18  9:38 ` harven

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.