[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding streams for standard out and standard err
From: |
Phillip Lord |
Subject: |
Re: Adding streams for standard out and standard err |
Date: |
Thu, 21 Jul 2016 19:52:58 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
>> From: address@hidden (Phillip Lord)
>> Date: Wed, 20 Jul 2016 23:48:43 +0100
>>
>> For a while I've wanted Emacs to have the ability to write to standard
>> out, and/or standard err, when not running in batch. Mostly, I've wanted
>> for debugging, as it involves touching no buffers at all.
>
> Can we take a step back and talk about the need and the use cases?
Mostly debugging, I think. For example, I find debugging the undo code
very taxing. Using GDB is hard because the debug code gets called so
often (I admit to being barely competent at using GDB). Logging to a
buffer touches other buffers. Logging to a variable works, but you can
only see the value of the variable when all is done.
Dumping to stdout, while interacting with a live emacs would give me an
independent channel to getting output, as well as post-hoc debugging.
> Here're some thoughts related to this:
>
> . We already have (append-to-file START END FILENAME), which can be
> used to write a buffer or a string to a file. FILENAME can be
> "/dev/stderr" on Posix platforms, for example, or it can be a real
> file name.
We do, and I am grateful that you pointed this out to me. But
append-to-file also writes to the mini-buffer. This makes interactive
use difficult, or painful. Of course, this could be fixed.
Still,
(append-to-file (print buffer-undo-list) nil "/dev/stderr")
seems clunky compared to:
(print buffer-undo-list 'stdout)
> . On TTY frames, writing to standard streams can end up on the
> screen, in which case it will mess up the display.
Yep. I would imagine that debugging to standard out will not become
popular as a tool for debugging TTY display.
> . On GUI frames, writing to standard streams can end up in some
> unpredictable place on the system, or even in the bitbucket,
> depending on what window system, desktop, and window manager are
> installed. On some systems, standard streams have invalid file
> descriptors in GUI sessions.
It can also end up in some entirely predictable place, which is enough.
> So this proposed functionality sounds (a) not really necessary, and
> (b) somewhat unreliable/dangerous. If you have specific use cases
> where the existing functionality doesn't fit the bill, and the issues
> mentioned above are non-issues, please describe those use cases.
I think it has no problems that append-to-file does not not have, and is
neater, more concise and it's use is clearer.
Probably adding a stdin stream would be good also; still, that's a
separate issue.
Phil
Re: Adding streams for standard out and standard err, Phil Sainty, 2016/07/22