* Writing to STDOUT from elisp
@ 2014-06-28 22:51 Craig Muth
2014-07-08 6:36 ` Mathias Dahl
0 siblings, 1 reply; 20+ messages in thread
From: Craig Muth @ 2014-06-28 22:51 UTC (permalink / raw)
To: emacs-devel
Is there a way to have elisp send a string to the STDOUT of the main
emacs process? So that it appears in the calling shell I launched
emacs from? (So I'll see it when I suspend or quit?)
Ty!
--Craig
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-06-28 22:51 Writing to STDOUT from elisp Craig Muth
@ 2014-07-08 6:36 ` Mathias Dahl
2014-07-08 7:03 ` Stephen J. Turnbull
2014-07-08 14:54 ` Eli Zaretskii
0 siblings, 2 replies; 20+ messages in thread
From: Mathias Dahl @ 2014-07-08 6:36 UTC (permalink / raw)
To: Craig Muth; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
Not sure this can be done without using batch mode. This is a small test I
just did on w32:
c:\> emacs.exe --batch --eval "(message """Test""")"
Test
On Sun, Jun 29, 2014 at 12:51 AM, Craig Muth <craig.muth@gmail.com> wrote:
> Is there a way to have elisp send a string to the STDOUT of the main
> emacs process? So that it appears in the calling shell I launched
> emacs from? (So I'll see it when I suspend or quit?)
>
> Ty!
> --Craig
>
>
[-- Attachment #2: Type: text/html, Size: 940 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-08 6:36 ` Mathias Dahl
@ 2014-07-08 7:03 ` Stephen J. Turnbull
2014-07-08 14:54 ` Eli Zaretskii
1 sibling, 0 replies; 20+ messages in thread
From: Stephen J. Turnbull @ 2014-07-08 7:03 UTC (permalink / raw)
To: Mathias Dahl; +Cc: Craig Muth, emacs-devel
See `princ' and friends.
Mathias Dahl writes:
> Not sure this can be done without using batch mode. This is a small test I
> just did on w32:
>
> c:\> emacs.exe --batch --eval "(message """Test""")"
> Test
>
>
>
> On Sun, Jun 29, 2014 at 12:51 AM, Craig Muth <craig.muth@gmail.com> wrote:
>
> > Is there a way to have elisp send a string to the STDOUT of the main
> > emacs process? So that it appears in the calling shell I launched
> > emacs from? (So I'll see it when I suspend or quit?)
> >
> > Ty!
> > --Craig
> >
> >
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-08 6:36 ` Mathias Dahl
2014-07-08 7:03 ` Stephen J. Turnbull
@ 2014-07-08 14:54 ` Eli Zaretskii
2014-07-08 15:38 ` Andreas Schwab
1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2014-07-08 14:54 UTC (permalink / raw)
To: Mathias Dahl; +Cc: craig.muth, emacs-devel
> From: Mathias Dahl <mathias.dahl@gmail.com>
> Date: Tue, 8 Jul 2014 08:36:18 +0200
> Cc: emacs-devel@gnu.org
>
> Not sure this can be done without using batch mode. This is a small test I
> just did on w32:
>
> c:\> emacs.exe --batch --eval "(message """Test""")"
> Test
'message' writes to stderr, not to stdout, so this is not what the OP
wanted.
Stephen's suggestion is better: it does write to stdout.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-08 14:54 ` Eli Zaretskii
@ 2014-07-08 15:38 ` Andreas Schwab
2014-07-08 17:02 ` Stephen J. Turnbull
0 siblings, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2014-07-08 15:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: craig.muth, emacs-devel, Mathias Dahl
Eli Zaretskii <eliz@gnu.org> writes:
> Stephen's suggestion is better: it does write to stdout.
It writes to the echo area.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-08 15:38 ` Andreas Schwab
@ 2014-07-08 17:02 ` Stephen J. Turnbull
2014-07-08 18:59 ` Andreas Schwab
0 siblings, 1 reply; 20+ messages in thread
From: Stephen J. Turnbull @ 2014-07-08 17:02 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Mathias Dahl, Eli Zaretskii, craig.muth, emacs-devel
Andreas Schwab writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Stephen's suggestion is better: it does write to stdout.
>
> It writes to the echo area.
See `standard-output'.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-08 17:02 ` Stephen J. Turnbull
@ 2014-07-08 18:59 ` Andreas Schwab
2014-07-09 1:50 ` Craig Muth
2014-07-09 3:55 ` Stephen J. Turnbull
0 siblings, 2 replies; 20+ messages in thread
From: Andreas Schwab @ 2014-07-08 18:59 UTC (permalink / raw)
To: Stephen J. Turnbull; +Cc: Eli Zaretskii, craig.muth, emacs-devel, Mathias Dahl
"Stephen J. Turnbull" <stephen@xemacs.org> writes:
> Andreas Schwab writes:
> > Eli Zaretskii <eliz@gnu.org> writes:
> >
> > > Stephen's suggestion is better: it does write to stdout.
> >
> > It writes to the echo area.
>
> See `standard-output'.
Yes. Did you look it up?
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-08 18:59 ` Andreas Schwab
@ 2014-07-09 1:50 ` Craig Muth
2014-07-09 2:48 ` Eli Zaretskii
` (3 more replies)
2014-07-09 3:55 ` Stephen J. Turnbull
1 sibling, 4 replies; 20+ messages in thread
From: Craig Muth @ 2014-07-09 1:50 UTC (permalink / raw)
To: Andreas Schwab
Cc: Stephen J. Turnbull, emacs-devel, Eli Zaretskii, Mathias Dahl
You can get princ to write to "standard-output", meaning the echo
area. I'm looking to write to the stdout of the whole process, so the
output shows up in the terminal you launched emacs in. So when you
exit emacs, you'll see the text in the shell.
I've asked around and am pretty sure elisp can't do this. I may have
found the one elemental thing that elisp can't do :)
--Craig
On Tue, Jul 8, 2014 at 11:59 AM, Andreas Schwab <schwab@suse.de> wrote:
> "Stephen J. Turnbull" <stephen@xemacs.org> writes:
>
>> Andreas Schwab writes:
>> > Eli Zaretskii <eliz@gnu.org> writes:
>> >
>> > > Stephen's suggestion is better: it does write to stdout.
>> >
>> > It writes to the echo area.
>>
>> See `standard-output'.
>
> Yes. Did you look it up?
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-09 1:50 ` Craig Muth
@ 2014-07-09 2:48 ` Eli Zaretskii
2014-07-10 2:45 ` Eli Zaretskii
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2014-07-09 2:48 UTC (permalink / raw)
To: Craig Muth; +Cc: schwab, stephen, emacs-devel, mathias.dahl
> Date: Tue, 8 Jul 2014 18:50:23 -0700
> From: Craig Muth <craig.muth@gmail.com>
> Cc: "Stephen J. Turnbull" <stephen@xemacs.org>, Mathias Dahl <mathias.dahl@gmail.com>,
> Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
>
> You can get princ to write to "standard-output", meaning the echo
> area. I'm looking to write to the stdout of the whole process, so the
> output shows up in the terminal you launched emacs in. So when you
> exit emacs, you'll see the text in the shell.
>
> I've asked around and am pretty sure elisp can't do this. I may have
> found the one elemental thing that elisp can't do :)
Please show what did you try and why do you think it didn't do what
you want.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-08 18:59 ` Andreas Schwab
2014-07-09 1:50 ` Craig Muth
@ 2014-07-09 3:55 ` Stephen J. Turnbull
2014-07-09 7:24 ` Andreas Schwab
1 sibling, 1 reply; 20+ messages in thread
From: Stephen J. Turnbull @ 2014-07-09 3:55 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Eli Zaretskii, craig.muth, emacs-devel, Mathias Dahl
Andreas Schwab writes:
> > See `standard-output'.
>
> Yes. Did you look it up?
Hm. This is harder than I thought. In XEmacs at least, it's trivial
in -batch mode[1], but interactively the initial stream console gets
deleted, and that dead console gets in the way of output to stdout.
Footnotes:
[1] Somehow xemacs -batch -f dunnet on the console just feels more
natural than playing in a GUI window. ;-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-09 3:55 ` Stephen J. Turnbull
@ 2014-07-09 7:24 ` Andreas Schwab
0 siblings, 0 replies; 20+ messages in thread
From: Andreas Schwab @ 2014-07-09 7:24 UTC (permalink / raw)
To: Stephen J. Turnbull; +Cc: Eli Zaretskii, craig.muth, emacs-devel, Mathias Dahl
"Stephen J. Turnbull" <stephen@xemacs.org> writes:
> Andreas Schwab writes:
>
> > > See `standard-output'.
> >
> > Yes. Did you look it up?
>
> Hm. This is harder than I thought. In XEmacs at least, it's trivial
> in -batch mode[1],
In batch mode the echo area is the stdout.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-09 1:50 ` Craig Muth
2014-07-09 2:48 ` Eli Zaretskii
@ 2014-07-10 2:45 ` Eli Zaretskii
2014-07-10 5:40 ` Craig Muth
2014-07-10 19:09 ` Johan Bockgård
2014-07-10 22:54 ` Johan Bockgård
3 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2014-07-10 2:45 UTC (permalink / raw)
To: Craig Muth; +Cc: schwab, stephen, mathias.dahl, emacs-devel
> Date: Tue, 8 Jul 2014 18:50:23 -0700
> From: Craig Muth <craig.muth@gmail.com>
> Cc: "Stephen J. Turnbull" <stephen@xemacs.org>, emacs-devel@gnu.org,
> Eli Zaretskii <eliz@gnu.org>, Mathias Dahl <mathias.dahl@gmail.com>
>
> You can get princ to write to "standard-output", meaning the echo
> area. I'm looking to write to the stdout of the whole process, so the
> output shows up in the terminal you launched emacs in. So when you
> exit emacs, you'll see the text in the shell.
You can do that with "emacs -batch", where princ writes to stdout.
If you want to do this in an interactive session, please tell what
exactly are you trying to do and why. For example, is this only
needed when you exit Emacs, or do you want to be able to write to
stdout and then continue to run Emacs for a while (and why)?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-10 2:45 ` Eli Zaretskii
@ 2014-07-10 5:40 ` Craig Muth
2014-07-10 15:03 ` Eli Zaretskii
0 siblings, 1 reply; 20+ messages in thread
From: Craig Muth @ 2014-07-10 5:40 UTC (permalink / raw)
To: Eli Zaretskii
Cc: Andreas Schwab, Stephen J. Turnbull, Mathias Dahl, emacs-devel
> If you want to do this in an interactive session
Yes, in an interactive session.
> please tell what
> exactly are you trying to do and why. For example, is this only
> needed when you exit Emacs
Doing it when exiting emacs would work. The best way to see what I'm
trying to do is to watch the first 20 seconds of the video on
http://xsh.org. Xsh runs in emacs (transparently for most users,
since most key shortcuts are redefined). I'm using a work-around to
do the printing for now. One possible work-around is to making xsh be
a bash script (or function) that runs emacs and then prints text it
finds in a file temp file to stdout. But it would be nice if I could
do it without that step.
--Craig
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-10 5:40 ` Craig Muth
@ 2014-07-10 15:03 ` Eli Zaretskii
2014-07-10 15:20 ` Lennart Borgman
0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2014-07-10 15:03 UTC (permalink / raw)
To: Craig Muth; +Cc: schwab, stephen, mathias.dahl, emacs-devel
> Date: Wed, 9 Jul 2014 22:40:09 -0700
> From: Craig Muth <craig.muth@gmail.com>
> Cc: Andreas Schwab <schwab@suse.de>, "Stephen J. Turnbull" <stephen@xemacs.org>, emacs-devel@gnu.org,
> Mathias Dahl <mathias.dahl@gmail.com>
>
> > If you want to do this in an interactive session
>
> Yes, in an interactive session.
>
> > please tell what
> > exactly are you trying to do and why. For example, is this only
> > needed when you exit Emacs
>
> Doing it when exiting emacs would work.
Then one way of doing this is call kill-emacs with a non-nil argument,
then wrap Emacs in a shell script that would do whatever you want
depending on the Emacs exit code.
Of course, submitting (trivial) patches for adding a command to write
to stdout would probably be welcome as well. But please note that
sometimes Emacs is invoked with stdout redirected to some obscure
file, or even with stdout being closed/invalid.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-10 15:03 ` Eli Zaretskii
@ 2014-07-10 15:20 ` Lennart Borgman
2014-07-10 18:01 ` Craig Muth
0 siblings, 1 reply; 20+ messages in thread
From: Lennart Borgman @ 2014-07-10 15:20 UTC (permalink / raw)
To: Eli Zaretskii
Cc: schwab, Stephen Turnbull, Craig Muth, Emacs-Devel devel,
Mathias Dahl
[-- Attachment #1: Type: text/plain, Size: 423 bytes --]
On Thu, Jul 10, 2014 at 5:03 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> Of course, submitting (trivial) patches for adding a command to write
> to stdout would probably be welcome as well. But please note that
> sometimes Emacs is invoked with stdout redirected to some obscure
> file, or even with stdout being closed/invalid.
>
> I used that very much for debugging before. Wonder if I still have that
code somewhere?
[-- Attachment #2: Type: text/html, Size: 962 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-10 15:20 ` Lennart Borgman
@ 2014-07-10 18:01 ` Craig Muth
2014-07-11 12:04 ` Thien-Thi Nguyen
0 siblings, 1 reply; 20+ messages in thread
From: Craig Muth @ 2014-07-10 18:01 UTC (permalink / raw)
To: Lennart Borgman
Cc: Andreas Schwab, Eli Zaretskii, Emacs-Devel devel,
Stephen Turnbull, Mathias Dahl
If you were able to dig up that code, that would be cool.
On a related note, I'd be curious to hear anyone's feedback about Xsh
(the video at the top is the best thing too check out):
http://xsh.org
--Craig
On Thu, Jul 10, 2014 at 8:20 AM, Lennart Borgman
<lennart.borgman@gmail.com> wrote:
> On Thu, Jul 10, 2014 at 5:03 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>
>>
>> Of course, submitting (trivial) patches for adding a command to write
>> to stdout would probably be welcome as well. But please note that
>> sometimes Emacs is invoked with stdout redirected to some obscure
>> file, or even with stdout being closed/invalid.
>>
> I used that very much for debugging before. Wonder if I still have that code
> somewhere?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-09 1:50 ` Craig Muth
2014-07-09 2:48 ` Eli Zaretskii
2014-07-10 2:45 ` Eli Zaretskii
@ 2014-07-10 19:09 ` Johan Bockgård
2014-07-10 19:25 ` Eli Zaretskii
2014-07-10 22:54 ` Johan Bockgård
3 siblings, 1 reply; 20+ messages in thread
From: Johan Bockgård @ 2014-07-10 19:09 UTC (permalink / raw)
To: emacs-devel
Craig Muth <craig.muth@gmail.com> writes:
> You can get princ to write to "standard-output", meaning the echo
> area. I'm looking to write to the stdout of the whole process, so the
> output shows up in the terminal you launched emacs in. So when you
> exit emacs, you'll see the text in the shell.
(write-region STRING nil "/dev/stdout")
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-10 19:09 ` Johan Bockgård
@ 2014-07-10 19:25 ` Eli Zaretskii
0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2014-07-10 19:25 UTC (permalink / raw)
To: Johan Bockgård; +Cc: emacs-devel
> From: Johan Bockgård <bojohan@gnu.org>
> Date: Thu, 10 Jul 2014 21:09:40 +0200
>
> (write-region STRING nil "/dev/stdout")
That's non-portable.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-09 1:50 ` Craig Muth
` (2 preceding siblings ...)
2014-07-10 19:09 ` Johan Bockgård
@ 2014-07-10 22:54 ` Johan Bockgård
3 siblings, 0 replies; 20+ messages in thread
From: Johan Bockgård @ 2014-07-10 22:54 UTC (permalink / raw)
To: emacs-devel
Craig Muth <craig.muth@gmail.com> writes:
> You can get princ to write to "standard-output", meaning the echo
> area. I'm looking to write to the stdout of the whole process, so the
> output shows up in the terminal you launched emacs in. So when you
> exit emacs, you'll see the text in the shell.
You can write to STDERR with `external-debugging-output'.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Writing to STDOUT from elisp
2014-07-10 18:01 ` Craig Muth
@ 2014-07-11 12:04 ` Thien-Thi Nguyen
0 siblings, 0 replies; 20+ messages in thread
From: Thien-Thi Nguyen @ 2014-07-11 12:04 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 112 bytes --]
Please find attached an old (needs love) patch to write
messages to stderr on exit. Perhaps it can be of use.
[-- Attachment #1.2: message-to-stderr-on-exit.mbox --]
[-- Type: application/mbox, Size: 2385 bytes --]
[-- Attachment #1.3: Type: text/plain, Size: 228 bytes --]
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2014-07-11 12:04 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-28 22:51 Writing to STDOUT from elisp Craig Muth
2014-07-08 6:36 ` Mathias Dahl
2014-07-08 7:03 ` Stephen J. Turnbull
2014-07-08 14:54 ` Eli Zaretskii
2014-07-08 15:38 ` Andreas Schwab
2014-07-08 17:02 ` Stephen J. Turnbull
2014-07-08 18:59 ` Andreas Schwab
2014-07-09 1:50 ` Craig Muth
2014-07-09 2:48 ` Eli Zaretskii
2014-07-10 2:45 ` Eli Zaretskii
2014-07-10 5:40 ` Craig Muth
2014-07-10 15:03 ` Eli Zaretskii
2014-07-10 15:20 ` Lennart Borgman
2014-07-10 18:01 ` Craig Muth
2014-07-11 12:04 ` Thien-Thi Nguyen
2014-07-10 19:09 ` Johan Bockgård
2014-07-10 19:25 ` Eli Zaretskii
2014-07-10 22:54 ` Johan Bockgård
2014-07-09 3:55 ` Stephen J. Turnbull
2014-07-09 7:24 ` Andreas Schwab
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).