Re: How do I handle ^M and ^H characters output from external programs?
- From: cstacy@xxxxxxxxxxxxx (Christopher C. Stacy)
- Date: Fri, 15 Jul 2005 06:32:51 GMT
Jeff Cunningham <jeffrey@xxxxxxxxxxxxxx> writes:
> On Tue, 12 Jul 2005 19:22:01 -0700, Jeff Cunningham wrote:
> > I have this code embedded in a process I'm running:
> >
> > (ext:process-exit-code
> > (ext:run-program "cdrecord" args
> > :output *standard-output*)))
> >
> > and it works fine, except that the cdrecord utility (and many others) uses
> > both backspace ^H and carriage return ^M to write updates to the screen.
> > This makes a big mess in the slime-repl window ,as they aren't properly
> > interpreted and so stuff spews out for miles before it finishes.
> >
> > Is there a way to capture these characters before they hit
> > *standard-output* and interpete them so they either work correctly or are
> > at least benign (i.e. convert carriage return to a linefeed, and any
> > sequence of backspaces ^H^H^H^H^H^H^H with a linefeed)?
This program that you're trying to run, "cdrecord", apparently
is not designed to have its output piped into some other program.
It expects to be talking to your terminal.
This is not really a Lisp issue.
*STANDARD-OUTPUT* is bound to some Lisp stream maintained by SLIME,
attached to an Emacs buffer. cdrecord was not designed to attach
to an Emacs buffer, or to anything other than a terminal (or some
program which emulates a terminal by understandin the control codes
for moving your cursor around).
You could use Simple Streams to write your own stream class which
understands those codes somehow (perhaps just turning them into
newlines or something). Where the data eventually goes is up
to you, but your stream could encapsulate *STANDARD-OUTPUT*,
acting as a filter. Then you could call RUN-PROGRAM with an
instance of your stream, rather than *STANDARD-OUTPUT*.
.
- Follow-Ups:
- Re: How do I handle ^M and ^H characters output from external programs?
- From: Jeff Cunningham
- Re: How do I handle ^M and ^H characters output from external programs?
- References:
- How do I handle ^M and ^H characters output from external programs?
- From: Jeff Cunningham
- Re: How do I handle ^M and ^H characters output from external programs?
- From: Jeff Cunningham
- How do I handle ^M and ^H characters output from external programs?
- Prev by Date: Re: What defines *really* knowing Lisp, in your opinion?
- Next by Date: Re: What's happening with The ANSI Common Lisp Reference Book
- Previous by thread: Re: How do I handle ^M and ^H characters output from external programs?
- Next by thread: Re: How do I handle ^M and ^H characters output from external programs?
- Index(es):
Relevant Pages
|