[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: with-current-buffer

From: Richard M. Stallman
Subject: Re: with-current-buffer
Date: Tue, 28 Jun 2005 14:47:43 -0400

    What causes trouble here is the fact that Emacs changes the current
    buffer behind the scenes (somewhere in the main loop), so at the end
    of the function it is not known what the buffer will be current after
    the function finishes.  But sometimes it is desirable to perform some
    actions on that buffer (e.g. run hooks).

I don't understand what you mean by "trouble"--the scenario is not
clearly specified.  It is a basic feature that the main loop sets the
current buffer.  It is a basic feature that with-current-buffer
preserves the current buffer.

    Maybe with-current-buffer should keep track of switching buffers
    inside with-current-buffer, so it could anticipate what a buffer will
    be set as current and don't restore the old buffer.

Certainly not.  with-current-buffer must do its job reliably.

    Or maybe `pop-to-buffer inside with-current-buffer' is not a suitable
    programming construct (I mean mostly for the `next-error' command
    where this problem occurred) 

There is nothing wrong with it in principle, no reason why it should
in general be avoided.  It might not be the right thing for the
specific place you have in mind.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]