[comp.emacs] Windows vs Buffers and current point...

patrick@COS.COM (Patrick Steranka) (08/20/87)

I have several questions that I hope someone on the net can help me with:

(1) What is the difference between set-window-buffer and
    switch-to-buffer ?

(2) What is the difference between set-buffer and switch-to-buffer?

(3) If you a LISP program to place the cursor into a particular buffer
    at a specific position, and remain there for the user to see HOW
    SHOULD YOU DO IT?
	I currently do this, is this correct?
	(pop-to-buffer buf-that-I-want-user-to-be-in)
	(goto-char position-where-i-want-cursor-to-be)


patrick (Patrick Steranka @ Corporation for Open Systems)
	-- patrick@cos.com
	-- {seismo!sundc, hadron, hqda-ai}!cos!patrick2

tom@uw-warp.UUCP (F. Thomas May) (08/23/87)

In article <405@cos.COM> patrick@COS.COM (Patrick Steranka) writes:

>I have several questions that I hope someone on the net can help me with:
>
>(1) What is the difference between set-window-buffer and
>    switch-to-buffer ?

set-window-buffer works with any window, switch-to-buffer works only
with the selected window.

>(2) What is the difference between set-buffer and switch-to-buffer?

switch-to-buffer changes the current buffer (the one in which editing
takes place) and displays it in the selected window (the one with the
cursor in it).  set-buffer changes the current buffer, but leaves the
same buffer displayed in the selected window.  Note, though, that when
it comes time to get more keyboard input, the buffer displayed in the
selected window becomes the current buffer, regardless of previous
set-buffers.  As the documentation for switch-to-buffer states, this
makes set-buffer the thing to use to work on another buffer
temporarily within a lisp function, since when the function returns
the current buffer will be restored to the buffer associated with the
selected window (which probably hasn't changed :-).  save-excursion is
also handy for doing this.

>(3) If you a LISP program to place the cursor into a particular buffer
>    at a specific position, and remain there for the user to see HOW
>    SHOULD YOU DO IT?
>	I currently do this, is this correct?
>	(pop-to-buffer buf-that-I-want-user-to-be-in)
>	(goto-char position-where-i-want-cursor-to-be)

That is correct, so long as you want to use pop-to-buffer and not
switch-to-buffer, which would also work.  Things like
find-file-other-window can also switch buffers/windows on you.

-- 
Tom May
uw-nsr!uw-warp!tom@beaver.cs.washington.edu
uw-beaver!uw-nsr!uw-warp!tom