[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: carriage-return no longer works quite right in shell-mode
From: |
Stefan Monnier |
Subject: |
Re: carriage-return no longer works quite right in shell-mode |
Date: |
Sun, 10 Feb 2008 21:55:51 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) |
> I recently updated Emacs from the CVS trunk and one of the programs
> I run inside a shell-mode buffer has stopped formatting its
> output correctly.
How old was your previous Emacs?
> It uses carriage return characters to re-write the same line over and
> over, and leaves the cursor at the beginning of the line. Here's a
> simplified example that no longer works in Emacs:
> #include <stdio.h>
> main() {
> int i;
> for (i = 0; i < 10; i++) {
> printf(" count: %d\r", i);
> fflush(stdout);
> sleep(1);
> }
> printf("\n");
> }
> Instead of re-writing the same part of the buffer over and over, I see:
> count: 0 count: 1 count: 2
> in the buffer - the carriage return isn't returning the carriage like
> it used to.
Hmm... I see that indeed.
> I notice that apt-get does still work - that leaves the cursor at the
> end of the line, which I guess is the important difference.
Yes. Funnily enough, in Emacs-22 the two behave identically because
when your program sends "count: N\r", Emacs passes the "count: N" to the
`shell' package, but keeps the \r for later because it needs to first
see if the following char is a \n or not in order to know whether to
drop the \r or not. I.e. the details of decoding DOS-style EOLs caused
Emacs to turn one form into the other.
So it indeed, looks like a problem introduced by the unicode merge: for
some reason, the unicode code just sends the \r eagerly before it can
tell whether the next char is a \n.
I'll keep it in my todo list, but it may take me a little while to get
back to it, so if someone wants to do it before, he's welcome,
Stefan