unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-devel@gnu.org
Subject: Re: switch-to-buffer: for interactive use only
Date: Thu, 07 Jul 2011 17:11:56 -0400	[thread overview]
Message-ID: <jwvmxgp3iqb.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <8739ihlsry.fsf@stupidchicken.com> (Chong Yidong's message of "Thu, 07 Jul 2011 16:50:25 -0400")

>>> 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	other threads:[~2011-07-07 21:11 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 21:40 switch-to-buffer: for interactive use only Glenn Morris
2011-07-05 23:23 ` Juanma Barranquero
2011-07-05 23:32   ` Glenn Morris
2011-07-05 23:34     ` Juanma Barranquero
2011-07-05 23:41     ` Juanma Barranquero
2011-07-06  1:18 ` Stefan Monnier
2011-07-06  1:49   ` Glenn Morris
2011-07-06  2:27     ` Glenn Morris
2011-07-06  5:55     ` Andreas Röhler
2011-07-06 21:10   ` Chong Yidong
2011-07-07  9:19     ` Štěpán Němec
2011-07-07 19:52     ` Stefan Monnier
2011-07-07 20:50       ` Chong Yidong
2011-07-07 21:11         ` Stefan Monnier [this message]
2011-07-07 23:39           ` Chong Yidong
2011-07-08  0:09             ` Juanma Barranquero
2011-07-08  1:12               ` Chong Yidong
2011-07-08  6:44               ` martin rudalics
2011-07-08  6:44             ` martin rudalics
2011-07-08  6:43           ` martin rudalics
2011-07-08 12:57             ` Stefan Monnier
2011-07-08 14:03               ` martin rudalics
2011-07-08 15:46                 ` Stefan Monnier
2011-07-08 16:45                   ` martin rudalics
2011-07-08 18:46                     ` Stefan Monnier
2011-07-08 20:12                       ` Chong Yidong
2011-07-08 20:34                         ` Juanma Barranquero
2011-07-08 20:50                           ` Chong Yidong
2011-07-08 23:16                             ` Juanma Barranquero
2011-07-09  2:35                               ` Chong Yidong
2011-07-09  3:09                                 ` Stefan Monnier
2011-07-09  8:45                                   ` martin rudalics
2011-07-11  3:41                                     ` Stefan Monnier
2011-07-11  9:43                                       ` martin rudalics
2011-07-09 19:25                                   ` Chong Yidong
2011-07-10  9:00                                     ` martin rudalics
2011-07-10 13:09                                       ` Chong Yidong
2011-07-10 13:31                                         ` martin rudalics
2011-07-11  3:45                                     ` Stefan Monnier
2011-07-11 14:56                                       ` Chong Yidong
2011-07-12  4:25                                         ` Stefan Monnier
2011-07-12  8:36                                           ` martin rudalics
2011-07-13 15:42                                             ` Chong Yidong
2011-07-13 17:18                                               ` martin rudalics
2011-07-13 21:53                                                 ` Chong Yidong
2011-07-09  8:45                                 ` martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2011-07-13 22:13 grischka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmxgp3iqb.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).