emacs-devel
[Top][All Lists]
Advanced

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

Re: switch-to-buffer: for interactive use only


From: Stefan Monnier
Subject: Re: switch-to-buffer: for interactive use only
Date: Thu, 07 Jul 2011 17:11:56 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>>> How would you change this?
>> 
>>> (defun unbury-buffer ()
>>> "Switch to the last buffer in the buffer list."
>>> (interactive)
>>> (switch-to-buffer (last-buffer)))
>> 
>> Either using with-no-warnings or using set-window-buffer.

> What's wrong with using switch-to-buffer?

> If you could elaborate a bit more on what bugs you are referring to when
> you say

>> Most of those calls were bugs waiting to catch you in Emacs<23 ("you"
>> being typically a user like myself who uses dedicated windows and/or
>> minibuffer-only frames).

> then maybe we could come up with a way to issue the warning more
> selectively.  Because AFAICT the usage in unbury-buffer, and probably
> many other places in Emacs, is completely correct, and I agree with
> Glenn that issuing a zillion warnings for this not satisfactory.

There are two different uses of switch-to-buffer:
- the ones like in unbury-buffer where the main point is that it
  operates on the selected window.
- the ones like in find-file where the main point is that it wants to
  display a given buffer.

In single-frame circumstances, the two cases are identical, so most
authors who use Emacs in a single-frame mode don't even realize that
there's a choice to be made.

Until Emacs-23, switch-to-buffer assumed the main point was to only
affect the selected-window (and hence signal an error if the switch is
not possible).

In Emacs-23, I've changed it to assume that the main point is to display
the given buffer (by delegating the job to pop-to-buffer if necessary).

Recently, I reverted my Emacs-23 change because it introduced bugs
(e.g. in unbury-buffer and bs--cycle-next).


        Stefan


PS: BTW, I think the interactive use of switch-to-buffer is "the second
case" (and should hence call pop-to-buffer-same-window).



reply via email to

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