Subject: bug#5924: 23.1; accept-process-output switching current-buffer

From: Uday S Reddy <[email-masked]>
Date: Sun, 11 Apr 2010 13:22:22 +0100

Stefan Monnier writes:

> > Reading the elisp manual doesn't indicate anywhere that a call such as 
> >    (accept-process-output process)
> > should change the current-buffer.
> 
> That depends on the code run during the wait.  I.e. it depends on the
> code run by the process filters, sentinels, timers, ...

Yes, indeed!  If there is code being run during accept-process-output
then the state can be changed by that code.  But in the example that I
witnessed, there was *no code* being run.

Looking at the manual again, it says in "Accepting Output from
Processes":

    "There are *two ways* to receive the output that a subprocess
    writes to its standard output stream.  The output can be inserted
    in a buffer, which is called the associated buffer of the process,
    or a function called the "filter function" can be called to act on
    the output."

In the second "way" that is being talked about, we can reasonably
expect that current-buffer might change during the execution of the
filter function.  But in the first "way", where Emacs is doing all the
work of accepting the process output, I don't think it should change
the current-buffer.  

> We've already fixed several bugs where process filters changed
> current-buffer, but I think we should fix it not in the process filters
> but in the code that run them.  At least, unless someone can come up
> with a scenario where a process filter, sentinel, or timer would need
> to change current-buffer.

I don't fully understand this, but let me say that I am just talking
about problem with the Elisp semantics, not Emacs libraries.  If a
filter function changed the current-buffer, one would regard it as
buggy.  But if Elisp itself changes the current-buffer...?

The other thing that concerns me is that the same behaviour persisted
even if I set the JUST-THIS-ONE flag to t.  In that case, one would
expect that Elisp would ignore the output from all other processes.
So, it should have no reason to change the current-buffer to the other
process.  But it did.  I am not sure if the JUST-THIS-ONE flag is
doing anything at all.

Cheers,
Uday

PS I have been looking at the emacs-developers list lately.  It is
quite amazing how much the guys talk, RMS included!