unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
@ 2004-09-02 18:59 Francis Litterio
  2004-09-02 19:57 ` Stefan Monnier
  0 siblings, 1 reply; 26+ messages in thread
From: Francis Litterio @ 2004-09-02 18:59 UTC (permalink / raw)


Revision 1.67 of lisp/buff-menu.el changed list-buffers-noselect so that
it now does

        (set-window-buffer (selected-window) buffer)

once for every buffer while building the buffer menu.  On my Windows XP
machine, this makes Emacs briefely display every buffer for a fraction
of a section before displaying the buffer menu.  Very annoying!

This patch fixes it without (apparently) causing a loss of
functionality:

--- buff-menu.el        02 Sep 2004 10:36:13 -0400      1.67
+++ buff-menu.el        02 Sep 2004 15:05:04 -0400      
@@ -641,7 +641,6 @@
                       (save-window-excursion
                         (setq name (buffer-name)
                               mode (progn
-                                     (set-window-buffer (selected-window) buffer)
                                      (concat (format-mode-line mode-name)
                                              (if mode-line-process
                                                  (format-mode-line mode-line-process))))

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-02 18:59 CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly! Francis Litterio
@ 2004-09-02 19:57 ` Stefan Monnier
  2004-09-02 20:07   ` Francis Litterio
  0 siblings, 1 reply; 26+ messages in thread
From: Stefan Monnier @ 2004-09-02 19:57 UTC (permalink / raw)
  Cc: emacs-devel

>         (set-window-buffer (selected-window) buffer)
> once for every buffer while building the buffer menu.  On my Windows XP
> machine, this makes Emacs briefely display every buffer for a fraction

Isn't it a bug that a redisplay would happen in that loop?
Which function in that loop lets redisplay happen?


        Stefan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-02 19:57 ` Stefan Monnier
@ 2004-09-02 20:07   ` Francis Litterio
  2004-09-02 20:48     ` Stefan Monnier
  0 siblings, 1 reply; 26+ messages in thread
From: Francis Litterio @ 2004-09-02 20:07 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier wrote:

>>         (set-window-buffer (selected-window) buffer)
>> once for every buffer while building the buffer menu.  On my Windows XP
>> machine, this makes Emacs briefely display every buffer for a fraction
>
> Isn't it a bug that a redisplay would happen in that loop?
> Which function in that loop lets redisplay happen?

It's definitely set-window-buffer, because when I remove the call to
that function, the symptom goes away.

Keep in mind that this is built on Windows XP.  I assume the underlying
display code is different for Windows than X.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-02 20:07   ` Francis Litterio
@ 2004-09-02 20:48     ` Stefan Monnier
  2004-09-03  6:27       ` Stephan Stahl
  2004-09-03 19:15       ` Francis Litterio
  0 siblings, 2 replies; 26+ messages in thread
From: Stefan Monnier @ 2004-09-02 20:48 UTC (permalink / raw)
  Cc: emacs-devel

>>> (set-window-buffer (selected-window) buffer)
>>> once for every buffer while building the buffer menu.  On my Windows XP
>>> machine, this makes Emacs briefely display every buffer for a fraction
>> 
>> Isn't it a bug that a redisplay would happen in that loop?
>> Which function in that loop lets redisplay happen?

> It's definitely set-window-buffer, because when I remove the call to
> that function, the symptom goes away.

It might be, but it's not necessarily the case: in Emacs, redisplay is
a separate operation from "changes to the buffer or the window layout".
`set-window-buffer' changes the window-layout which means it changes "what
will be displayed at next redisplay" but it shouldn't call
redisplay itself.

My question is not directly related to your problem, in the sense that
I think your patch is OK (except it should add a comment explaining why we
removed the call to set-window-buffer), but I think that your problem also
exposed another bug in the C code.


        Stefan

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-02 20:48     ` Stefan Monnier
@ 2004-09-03  6:27       ` Stephan Stahl
  2004-09-03 11:49         ` Francis Litterio
  2004-09-03 18:54         ` Kevin Rodgers
  2004-09-03 19:15       ` Francis Litterio
  1 sibling, 2 replies; 26+ messages in thread
From: Stephan Stahl @ 2004-09-03  6:27 UTC (permalink / raw)
  Cc: Francis Litterio, emacs-devel

Hi Stefan, Francis.

Stefan Monnier said:

>>>> (set-window-buffer (selected-window) buffer)
>>>> once for every buffer while building the buffer menu.  On my Windows
>>>> XP
>>>> machine, this makes Emacs briefely display every buffer for a fraction
>>>
>>> Isn't it a bug that a redisplay would happen in that loop?
>>> Which function in that loop lets redisplay happen?
>
>> It's definitely set-window-buffer, because when I remove the call to
>> that function, the symptom goes away.

That line in list-buffer-noselect was introduced by a patch from me.
Revision 1.67: (list-buffers-noselect): Append the buffer's process status
to its mode name.

If it is removed the following code in buff-menu.el will not work correctly:
mode (progn
       (set-window-buffer (selected-window) buffer)
       (concat (format-mode-line mode-name)
               (if mode-line-process
                   (format-mode-line mode-line-process))))
                   file (buffer-file-name)))

format-mode-line will only work correctly if it is called while the buffer
is selected. A way to reproduce the bug is: remove that line. start two
shells. kill one of them and do C-x C-b. Now the added information about
the process status is not correct. If you do C-x C-b from the running
shell both are shown with ":run". From the killed shell both will show
":exit [0]".
In fact that will be that case for all buffers with a process..

> It might be, but it's not necessarily the case: in Emacs, redisplay is
> a separate operation from "changes to the buffer or the window layout".
> `set-window-buffer' changes the window-layout which means it changes "what
> will be displayed at next redisplay" but it shouldn't call
> redisplay itself.
>
> My question is not directly related to your problem, in the sense that
> I think your patch is OK (except it should add a comment explaining why we
> removed the call to set-window-buffer), but I think that your problem also
> exposed another bug in the C code.

I tested my patch on both Debian GNU/Linux and WXP.  Maybe i did not look
close enough to notice that bug. I think we should try to find it and only
if that fails revert my patch..

Stephan
-- 
Stephan Stahl

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-03  6:27       ` Stephan Stahl
@ 2004-09-03 11:49         ` Francis Litterio
  2004-09-04  3:28           ` Richard Stallman
  2004-09-03 18:54         ` Kevin Rodgers
  1 sibling, 1 reply; 26+ messages in thread
From: Francis Litterio @ 2004-09-03 11:49 UTC (permalink / raw)


Stephan Stahl wrote:

> I tested my patch on both Debian GNU/Linux and WXP.  Maybe i did not look
> close enough to notice that bug.

I noticed the problem when I had over twenty buffers in existance.
Perhaps on a very fast machine with only a few buffers, the redisplay is
so fast that it isn't noticable.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-03  6:27       ` Stephan Stahl
  2004-09-03 11:49         ` Francis Litterio
@ 2004-09-03 18:54         ` Kevin Rodgers
  2004-09-04  8:42           ` Stephan Stahl
  2004-09-04 22:12           ` Richard Stallman
  1 sibling, 2 replies; 26+ messages in thread
From: Kevin Rodgers @ 2004-09-03 18:54 UTC (permalink / raw)


Stephan Stahl wrote:
 > That line in list-buffer-noselect was introduced by a patch from me.
 > Revision 1.67: (list-buffers-noselect): Append the buffer's process status
 > to its mode name.
 >
 > If it is removed the following code in buff-menu.el will not work correctly:
 > mode (progn
 >        (set-window-buffer (selected-window) buffer)
 >        (concat (format-mode-line mode-name)
 >                (if mode-line-process
 >                    (format-mode-line mode-line-process))))
 >                    file (buffer-file-name)))
 >
 > format-mode-line will only work correctly if it is called while the buffer
 > is selected.

But you have not only selected the buffer, you have modified the
buffer-window correspondence, and the doc string hints that you might
have forced a redisplay:

,----[ C-h f set-window-buffer RET ]
| set-window-buffer is a built-in function.
| (set-window-buffer WINDOW BUFFER)
|
| Make WINDOW display BUFFER as its contents.
| BUFFER can be a buffer or buffer name.
`----

Does replacing (progn (set-window-buffer ...) ...) with
(with-current-buffer (set-buffer buffer) ...) work?

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-02 20:48     ` Stefan Monnier
  2004-09-03  6:27       ` Stephan Stahl
@ 2004-09-03 19:15       ` Francis Litterio
  1 sibling, 0 replies; 26+ messages in thread
From: Francis Litterio @ 2004-09-03 19:15 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier wrote:

> `set-window-buffer' changes the window-layout which means it changes "what
> will be displayed at next redisplay" but it shouldn't call
> redisplay itself.

Near line 2979 of src/window.c, in function set_window_buffer() is this code:

  /* Update time stamps of buffer display.  */
  if (INTEGERP (b->display_count))
    XSETINT (b->display_count, XINT (b->display_count) + 1);
  b->display_time = Fcurrent_time ();

Could that be causing the redisplay?
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-03 11:49         ` Francis Litterio
@ 2004-09-04  3:28           ` Richard Stallman
  0 siblings, 0 replies; 26+ messages in thread
From: Richard Stallman @ 2004-09-04  3:28 UTC (permalink / raw)
  Cc: emacs-devel

    I noticed the problem when I had over twenty buffers in existance.
    Perhaps on a very fast machine with only a few buffers, the redisplay is
    so fast that it isn't noticable.

The question is, why does it call redisplay at all?  This happens in a
save-window-excursion which doesn't have very much in it.  Nothing
in there ought to call redisplay.  If something does, what is it?

If you put a breakpoint at Fredisplay, and you are willing
to debug with some patience as it hits this breakpoint,
you could make a C backtrace that would tell us the answer.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-03 18:54         ` Kevin Rodgers
@ 2004-09-04  8:42           ` Stephan Stahl
  2004-09-04 19:40             ` Francis Litterio
  2004-09-04 22:12           ` Richard Stallman
  1 sibling, 1 reply; 26+ messages in thread
From: Stephan Stahl @ 2004-09-04  8:42 UTC (permalink / raw)
  Cc: emacs-devel

Hi Kevin.

Kevin Rodgers <ihs_4664@yahoo.com> writes:

> But you have not only selected the buffer, you have modified the
> buffer-window correspondence, and the doc string hints that you might
> have forced a redisplay:
[...]
> Does replacing (progn (set-window-buffer ...) ...) with
> (with-current-buffer (set-buffer buffer) ...) work?

No that does not work.  Inside the loop that creates the buffer list
is a (with-current-buffer buffer).  The additional (set-buffer buffer)
you suggested does not make a difference.

It think we should take a look at Francis Litterio's posting maybe he
found the right spot.

Stephan
-- 
Stephan Stahl

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-04  8:42           ` Stephan Stahl
@ 2004-09-04 19:40             ` Francis Litterio
  0 siblings, 0 replies; 26+ messages in thread
From: Francis Litterio @ 2004-09-04 19:40 UTC (permalink / raw)


Stephan Stahl wrote:

> Kevin Rodgers writes:
>
>> But you have not only selected the buffer, you have modified the
>> buffer-window correspondence, and the doc string hints that you might
>> have forced a redisplay:
> [...]
>> Does replacing (progn (set-window-buffer ...) ...) with
>> (with-current-buffer (set-buffer buffer) ...) work?
>
> No that does not work.  Inside the loop that creates the buffer list
> is a (with-current-buffer buffer).  The additional (set-buffer buffer)
> you suggested does not make a difference.

If, in order to read text from the mode line for every buffer, we must
force the mode line for every buffer to be redisplayed (along with the
buffer itself), then _preventing_ redisplay from happening in this code
will prevent the code from reading text from the mode line of every
buffer, which was its original goal.

IMHO, briefly displaying every buffer is an unacceptable price to pay to
be able to read the mode line for every buffer.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-03 18:54         ` Kevin Rodgers
  2004-09-04  8:42           ` Stephan Stahl
@ 2004-09-04 22:12           ` Richard Stallman
  1 sibling, 0 replies; 26+ messages in thread
From: Richard Stallman @ 2004-09-04 22:12 UTC (permalink / raw)
  Cc: emacs-devel

    Does replacing (progn (set-window-buffer ...) ...) with
    (with-current-buffer (set-buffer buffer) ...) work?

That won't work now, because format-mode-line uses the buffer
from the window it uses.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
@ 2004-09-05  5:12 Richard Stallman
  2004-09-07 15:42 ` Francis Litterio
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Richard Stallman @ 2004-09-05  5:12 UTC (permalink / raw)


This patch adds a BUFFER argument to format-mode-line, and should
make it possible to avoid calling set-window-buffer in that loop.

However, I still think we should find out why redisplay
happens inside that loop, since in all appearance, there should
be no redisplay.


*** xdisp.c	03 Sep 2004 16:38:31 -0400	1.904
--- xdisp.c	05 Sep 2004 01:06:54 -0400	
***************
*** 15776,15790 ****
  
  
  DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line,
!        0, 3, 0,
         doc: /* Return the mode-line of selected window as a string.
  First optional arg FORMAT specifies a different format string (see
  `mode-line-format' for details) to use.  If FORMAT is t, return
  the buffer's header-line.  Second optional arg WINDOW specifies a
  different window to use as the context for the formatting.
! If third optional arg NO-PROPS is non-nil, string is not propertized.  */)
!      (format, window, no_props)
!      Lisp_Object format, window, no_props;
  {
    struct it it;
    int len;
--- 15776,15791 ----
  
  
  DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line,
!        0, 4, 0,
         doc: /* Return the mode-line of selected window as a string.
  First optional arg FORMAT specifies a different format string (see
  `mode-line-format' for details) to use.  If FORMAT is t, return
  the buffer's header-line.  Second optional arg WINDOW specifies a
  different window to use as the context for the formatting.
! If third optional arg NO-PROPS is non-nil, string is not propertized.
! Fourth optional arg BUFFER specifies which buffer to use.  */)
!   (format, window, no_props, buffer)
!      Lisp_Object format, window, no_props, buffer;
  {
    struct it it;
    int len;
***************
*** 15796,15807 ****
      window = selected_window;
    CHECK_WINDOW (window);
    w = XWINDOW (window);
-   CHECK_BUFFER (w->buffer);
  
!   if (XBUFFER (w->buffer) != current_buffer)
      {
        old_buffer = current_buffer;
!       set_buffer_internal_1 (XBUFFER (w->buffer));
      }
  
    if (NILP (format) || EQ (format, Qt))
--- 15797,15812 ----
      window = selected_window;
    CHECK_WINDOW (window);
    w = XWINDOW (window);
  
!   if (NILP (buffer))
!     buffer = w->buffer;
! 
!   CHECK_BUFFER (buffer);
! 
!   if (XBUFFER (buffer) != current_buffer)
      {
        old_buffer = current_buffer;
!       set_buffer_internal_1 (XBUFFER (buffer));
      }
  
    if (NILP (format) || EQ (format, Qt))

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-05  5:12 Richard Stallman
@ 2004-09-07 15:42 ` Francis Litterio
  2004-09-08  0:22   ` Richard Stallman
  2004-09-08 14:36 ` Francis Litterio
  2004-09-08 15:02 ` Francis Litterio
  2 siblings, 1 reply; 26+ messages in thread
From: Francis Litterio @ 2004-09-07 15:42 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman wrote:

> However, I still think we should find out why redisplay
> happens inside that loop, since in all appearance, there should
> be no redisplay.

Near line 2979 of src/window.c, in function set_window_buffer() is this code:

  /* Update time stamps of buffer display.  */
  if (INTEGERP (b->display_count))
    XSETINT (b->display_count, XINT (b->display_count) + 1);
  b->display_time = Fcurrent_time ();

Could that be causing the redisplay?
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-07 15:42 ` Francis Litterio
@ 2004-09-08  0:22   ` Richard Stallman
  0 siblings, 0 replies; 26+ messages in thread
From: Richard Stallman @ 2004-09-08  0:22 UTC (permalink / raw)
  Cc: emacs-devel

    Near line 2979 of src/window.c, in function set_window_buffer() is this code:

      /* Update time stamps of buffer display.  */
      if (INTEGERP (b->display_count))
	XSETINT (b->display_count, XINT (b->display_count) + 1);
      b->display_time = Fcurrent_time ();

    Could that be causing the redisplay?

Redisplay only occurs when something calls the C function `redisplay'
or `redisplay_preserve_echo_area'.

(Neither of these fields display_count and display_time seems to have
any effect on redisplay.)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-05  5:12 Richard Stallman
  2004-09-07 15:42 ` Francis Litterio
@ 2004-09-08 14:36 ` Francis Litterio
  2004-09-09  4:02   ` Richard Stallman
  2004-09-08 15:02 ` Francis Litterio
  2 siblings, 1 reply; 26+ messages in thread
From: Francis Litterio @ 2004-09-08 14:36 UTC (permalink / raw)
  Cc: Stephan Stahl, Kevin Rodgers, Richard Stallman, Stefan Monnier

Richard Stallman wrote:

> However, I still think we should find out why redisplay
> happens inside that loop, since in all appearance, there should
> be no redisplay.

I think I found the cause of the problem.  Here are the details:

1. list-buffers-noselect calls set-window-buffer once for every buffer.

2. set-window-buffer calls the functions on window-scroll-functions.

3. The problem only happens when I'm running ERC (the Emacs IRC client).

4. ERC adds the function erc-scroll-to-bottom to window-scroll-functions
   (locally in each ERC buffer).

5. erc-scroll-to-bottom calls recenter.

6. recenter's docstring says "Center point in window and redisplay
   frame." but I can't find a code path that leads from recenter to
   redisplay.

Despite not being able to find the actual call to redisplay, I think
that this explains the behavior I was seeing.  Can someone who knows
Emacs display logic better than me confirm or deny my conclusion?

Question: Since set-window-buffer calls the hooks on
window-scroll-functions, should list-buffers-noselect be changed to
avoid this potential for redisplay?
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-05  5:12 Richard Stallman
  2004-09-07 15:42 ` Francis Litterio
  2004-09-08 14:36 ` Francis Litterio
@ 2004-09-08 15:02 ` Francis Litterio
  2004-09-08 16:20   ` Kevin Rodgers
  2 siblings, 1 reply; 26+ messages in thread
From: Francis Litterio @ 2004-09-08 15:02 UTC (permalink / raw)
  Cc: Stephan Stahl, Kevin Rodgers, Richard Stallman, Stefan Monnier

I wrote:

> 1. list-buffers-noselect calls set-window-buffer once for every buffer.
> 
> 2. set-window-buffer calls the functions on window-scroll-functions.
> 
> 3. The problem only happens when I'm running ERC (the Emacs IRC client).
> 
> 4. ERC adds the function erc-scroll-to-bottom to window-scroll-functions
>    (locally in each ERC buffer).
> 
> 5. erc-scroll-to-bottom calls recenter.

In fact, erc-scroll-to-bottom calls (sit-for 0), and sit_for calls
redisplay_preserve_echo_area.

I think this solves the puzzle, though we have to decide if
list-buffers-noselect should continue to call set-window-buffer, given
that set-window-buffer calls the hooks on window-scroll-functions.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-08 15:02 ` Francis Litterio
@ 2004-09-08 16:20   ` Kevin Rodgers
  2004-09-08 18:21     ` Francis Litterio
  0 siblings, 1 reply; 26+ messages in thread
From: Kevin Rodgers @ 2004-09-08 16:20 UTC (permalink / raw)


Francis Litterio wrote:
 > I wrote:
 >>1. list-buffers-noselect calls set-window-buffer once for every buffer.
 >>
 >>2. set-window-buffer calls the functions on window-scroll-functions.
 >>
 >>3. The problem only happens when I'm running ERC (the Emacs IRC client).
 >>
 >>4. ERC adds the function erc-scroll-to-bottom to window-scroll-functions
 >>   (locally in each ERC buffer).
 >>
 >>5. erc-scroll-to-bottom calls recenter.
 >
 > In fact, erc-scroll-to-bottom calls (sit-for 0), and sit_for calls
 > redisplay_preserve_echo_area.
 >
 > I think this solves the puzzle, though we have to decide if
 > list-buffers-noselect should continue to call set-window-buffer, given
 > that set-window-buffer calls the hooks on window-scroll-functions.

Would it be reasonable for list-buffers-noselect to let-bind
window-scroll-functions to nil?

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-08 16:20   ` Kevin Rodgers
@ 2004-09-08 18:21     ` Francis Litterio
  2004-09-09  4:03       ` Richard Stallman
  2004-09-09  8:23       ` Stephan Stahl
  0 siblings, 2 replies; 26+ messages in thread
From: Francis Litterio @ 2004-09-08 18:21 UTC (permalink / raw)
  Cc: Kevin Rodgers

Kevin Rodgers wrote:

> Francis Litterio wrote:

>  > I think this solves the puzzle, though we have to decide if
>  > list-buffers-noselect should continue to call set-window-buffer, given
>  > that set-window-buffer calls the hooks on window-scroll-functions.
>
> Would it be reasonable for list-buffers-noselect to let-bind
> window-scroll-functions to nil?

RMS's patch adds a BUFFER argument to format-mode-line, which makes it
possible to avoid calling set-window-buffer in list-buffers-noselect, as
follows:

--- buff-menu.el	02 Sep 2004 10:36:13 -0400	1.67
+++ buff-menu.el	08 Sep 2004 14:32:06 -0400	
@@ -641,10 +641,10 @@
 		       (save-window-excursion
 			 (setq name (buffer-name)
 			       mode (progn
-				      (set-window-buffer (selected-window) buffer)
-				      (concat (format-mode-line mode-name)
+				      (concat (format-mode-line mode-name nil nil buffer)
 					      (if mode-line-process
-						  (format-mode-line mode-line-process))))
+						  (format-mode-line mode-line-process nil nil
+								    buffer))))
 			       file (buffer-file-name)))
 		       (cond
 			;; Don't mention internal buffers.

That is probably the optimal solution.  I would also suggest changing
the docstring for set-window-buffer to mention that it runs the hooks on
window-scroll-functions.  This patch makes that change:

--- window.c	02 Sep 2004 10:37:48 -0400	1.477
+++ window.c	08 Sep 2004 14:25:44 -0400	
@@ -3057,7 +3057,9 @@
 Optional third arg KEEP-MARGINS non-nil means that WINDOW's current
 display margins, fringe widths, and scroll bar settings are maintained;
 the default is to reset these from BUFFER's local settings or the frame
-defaults.  */)
+defaults.
+
+This function calls the functions on the hook window-scroll-functions.  */)
      (window, buffer, keep_margins)
      register Lisp_Object window, buffer, keep_margins;
 {

Hope this helps.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-08 14:36 ` Francis Litterio
@ 2004-09-09  4:02   ` Richard Stallman
  2004-09-09 15:46     ` Francis Litterio
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Stallman @ 2004-09-09  4:02 UTC (permalink / raw)
  Cc: stahl, ihs_4664, monnier, emacs-devel

    Despite not being able to find the actual call to redisplay, I think
    that this explains the behavior I was seeing.

I believe you are right--it sounds entirely plausible.

I fixed this so it no longer needs to call set-window-buffer.
Does the new source code work right for you?

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-08 18:21     ` Francis Litterio
@ 2004-09-09  4:03       ` Richard Stallman
  2004-09-09  8:23       ` Stephan Stahl
  1 sibling, 0 replies; 26+ messages in thread
From: Richard Stallman @ 2004-09-09  4:03 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel

    That is probably the optimal solution.  I would also suggest changing
    the docstring for set-window-buffer to mention that it runs the hooks on
    window-scroll-functions.

Thanks.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-08 18:21     ` Francis Litterio
  2004-09-09  4:03       ` Richard Stallman
@ 2004-09-09  8:23       ` Stephan Stahl
  2004-09-09 15:41         ` Francis Litterio
  2004-09-09 15:45         ` Richard Stallman
  1 sibling, 2 replies; 26+ messages in thread
From: Stephan Stahl @ 2004-09-09  8:23 UTC (permalink / raw)
  Cc: Kevin Rodgers, emacs-devel

(I did not include emacs-develand the others in my reply..
so here it goes again)

Hi Francis.

Francis Litterio said:

> RMS's patch adds a BUFFER argument to format-mode-line, which makes it
> possible to avoid calling set-window-buffer in list-buffers-noselect, as
> follows:
>
> --- buff-menu.el        02 Sep 2004 10:36:13 -0400        1.67
> +++ buff-menu.el        08 Sep 2004 14:32:06 -0400
> @@ -641,10 +641,10 @@
>                         (save-window-excursion
>                           (setq name (buffer-name)
>                                 mode (progn
> -                                      (set-window-buffer (selected-window) buffer)
> -                                      (concat (format-mode-line mode-name)
> +                                      (concat (format-mode-line mode-name nil nil buffer)
>                                                (if mode-line-process
> -                                                  (format-mode-line mode-line-process))))
> +                                                  (format-mode-line mode-line-process nil nil
> +                                                                    buffer))))
>                                 file (buffer-file-name)))
>                         (cond
>                          ;; Don't mention internal buffers.

Could you please try to verify if this really works?  I tried the same
thing but i did not get the right results.  My testcase was M-x shell,
M-x rename-uniquely, M-x shell, exit.  Now i have two shell buffers,
one running, one not. C-x C-b from the running shell adds ":run" to
both buffers in the buffer-list. The same thing from the finished
shell adds ":exit [0]" to both.  I have not found time to take a
closer look at why Richards patch does not seem to work for me.  And
yes i applied Richards patch and recompiled emacs ;-).

Oh with this simpler patch the progn could be omitted.

Stephan
-- 
Stephan Stahl

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-09  8:23       ` Stephan Stahl
@ 2004-09-09 15:41         ` Francis Litterio
  2004-09-09 16:13           ` Stephan Stahl
  2004-09-09 15:45         ` Richard Stallman
  1 sibling, 1 reply; 26+ messages in thread
From: Francis Litterio @ 2004-09-09 15:41 UTC (permalink / raw)
  Cc: Stephan Stahl

Stephan Stahl wrote:

> Could you please try to verify if this really works?  I tried the same
> thing but i did not get the right results.  My testcase was M-x shell,
> M-x rename-uniquely, M-x shell, exit.  Now i have two shell buffers,
> one running, one not. C-x C-b from the running shell adds ":run" to
> both buffers in the buffer-list. The same thing from the finished
> shell adds ":exit [0]" to both.

I just cvs up'ed my Emacs tree, rebuilt, and reinstalled, and it works
for me.  After following the steps in your testcase above, I get these
two lines in my *Buffer List* buffer:

  * *shell*<2>                            14  Shell:run		~/
  * *shell*                               51  Shell:no process	~/

which I believe is the correct behavior.

Perhaps you did not fetch RMS's patch to format-mode-line?
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-09  8:23       ` Stephan Stahl
  2004-09-09 15:41         ` Francis Litterio
@ 2004-09-09 15:45         ` Richard Stallman
  1 sibling, 0 replies; 26+ messages in thread
From: Richard Stallman @ 2004-09-09 15:45 UTC (permalink / raw)
  Cc: franl, ihs_4664, emacs-devel

    Could you please try to verify if this really works?  I tried the same
    thing but i did not get the right results.  My testcase was M-x shell,
    M-x rename-uniquely, M-x shell, exit.  Now i have two shell buffers,
    one running, one not. C-x C-b from the running shell adds ":run" to
    both buffers in the buffer-list. The same thing from the finished
    shell adds ":exit [0]" to both.

I see why this does not work.  It is because decode_mode_spec
gets the buffer out of the window.  It does not use the
current buffer.

I think I fixed that now.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-09  4:02   ` Richard Stallman
@ 2004-09-09 15:46     ` Francis Litterio
  0 siblings, 0 replies; 26+ messages in thread
From: Francis Litterio @ 2004-09-09 15:46 UTC (permalink / raw)
  Cc: Richard Stallman

Richard Stallman wrote:

>     Despite not being able to find the actual call to redisplay, I think
>     that this explains the behavior I was seeing.
>
> I believe you are right--it sounds entirely plausible.
>
> I fixed this so it no longer needs to call set-window-buffer.
> Does the new source code work right for you?

Yes.  It's working correctly now.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly!
  2004-09-09 15:41         ` Francis Litterio
@ 2004-09-09 16:13           ` Stephan Stahl
  0 siblings, 0 replies; 26+ messages in thread
From: Stephan Stahl @ 2004-09-09 16:13 UTC (permalink / raw)
  Cc: Stephan Stahl, emacs-devel

Hi Francis.

Francis Litterio said:

> I just cvs up'ed my Emacs tree, rebuilt, and reinstalled, and it works
> for me.  After following the steps in your testcase above, I get these
> two lines in my *Buffer List* buffer:
[....]
> Perhaps you did not fetch RMS's patch to format-mode-line?

I did (as i wrote in my mail).  But RMS also answered to my mail:

> I see why this does not work.  It is because decode_mode_spec
> gets the buffer out of the window.  It does not use the
> current buffer.
>
> I think I fixed that now.

So maybe you already got that new patch and that's why it worked?

Thanks for your help!

Stephan
-- 
Stephan Stahl

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2004-09-09 16:13 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-02 18:59 CVS Emacs list-buffer-noselect calls set-window-buffer, displays every buffer briefly! Francis Litterio
2004-09-02 19:57 ` Stefan Monnier
2004-09-02 20:07   ` Francis Litterio
2004-09-02 20:48     ` Stefan Monnier
2004-09-03  6:27       ` Stephan Stahl
2004-09-03 11:49         ` Francis Litterio
2004-09-04  3:28           ` Richard Stallman
2004-09-03 18:54         ` Kevin Rodgers
2004-09-04  8:42           ` Stephan Stahl
2004-09-04 19:40             ` Francis Litterio
2004-09-04 22:12           ` Richard Stallman
2004-09-03 19:15       ` Francis Litterio
  -- strict thread matches above, loose matches on Subject: below --
2004-09-05  5:12 Richard Stallman
2004-09-07 15:42 ` Francis Litterio
2004-09-08  0:22   ` Richard Stallman
2004-09-08 14:36 ` Francis Litterio
2004-09-09  4:02   ` Richard Stallman
2004-09-09 15:46     ` Francis Litterio
2004-09-08 15:02 ` Francis Litterio
2004-09-08 16:20   ` Kevin Rodgers
2004-09-08 18:21     ` Francis Litterio
2004-09-09  4:03       ` Richard Stallman
2004-09-09  8:23       ` Stephan Stahl
2004-09-09 15:41         ` Francis Litterio
2004-09-09 16:13           ` Stephan Stahl
2004-09-09 15:45         ` Richard Stallman

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).