[Top][All Lists]

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

Re: with-current-buffer

From: Luc Teirlinck
Subject: Re: with-current-buffer
Date: Sun, 11 Sep 2005 15:23:11 -0500 (CDT)

Emilio Lopes wrote:

   Display a buffer, let's say "FOO", with some content.  Move point to
   its beginning.

   Insert the following code in the "*scratch*" buffer:

      (with-current-buffer "FOO"
        (goto-char (point-max))
        (insert "bar"))

   Now execute the code above in these two different situations:

      1- The buffer "FOO" is visible along with the "*scratch*" buffer.

      2- The buffer "FOO" is not visible.

   In both cases the insertion is done at the right spot, but in case 1
   point in buffer "FOO" is restored after the code is executed.

Point in the buffer is not restored in either case.  Just execute:
(with-current-buffer "FOO" (point)) immediately afterwards.  You will
see that point _in the buffer_ really is where you expect it to be.

But each window that displays the buffer has its own value of point.
That value would not be restored either, if you would change it.  But
your code never changes it.  You should use set-window-point, if that
is what you want to do,

   Is that intended behavior?

I definitely believe that it is intended.



reply via email to

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