From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: switch-buffer to use other window if dedicated window (was: Jumping to C source from *Help*) Date: Thu, 8 Apr 2004 10:27:13 -0700 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <877jwqfmjb.fsf-monnier+emacs@alfajor.local> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1081445955 18736 80.91.224.253 (8 Apr 2004 17:39:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Apr 2004 17:39:15 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Apr 08 19:39:00 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BBdUS-00035Q-00 for ; Thu, 08 Apr 2004 19:39:00 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BBdUR-0007be-00 for ; Thu, 08 Apr 2004 19:39:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BBdSn-0005I4-9j for emacs-devel@quimby.gnus.org; Thu, 08 Apr 2004 13:37:17 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BBdRf-00054n-5z for emacs-devel@gnu.org; Thu, 08 Apr 2004 13:36:07 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BBdNN-0003ev-KA for emacs-devel@gnu.org; Thu, 08 Apr 2004 13:32:13 -0400 Original-Received: from [141.146.126.229] (helo=agminet02.oracle.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.30) id 1BBdNM-0003e5-LP for emacs-devel@gnu.org; Thu, 08 Apr 2004 13:31:40 -0400 Original-Received: from rgmgw5.us.oracle.com (rgmgw5.us.oracle.com [138.1.191.14]) by agminet02.oracle.com (Switch-3.1.2/Switch-3.1.0) with ESMTP id i38HRJsr011306; Thu, 8 Apr 2004 10:28:09 -0700 Original-Received: from rgmgw5.us.oracle.com (localhost [127.0.0.1]) by rgmgw5.us.oracle.com (Switch-2.1.5/Switch-2.1.0) with ESMTP id i38HRHE21772; Thu, 8 Apr 2004 11:27:17 -0600 (MDT) Original-Received: from dradamslap (dradams-lap.us.oracle.com [130.35.177.126]) by rgmgw5.us.oracle.com (Switch-2.1.5/Switch-2.1.0) with SMTP id i38HRDE21619; Thu, 8 Apr 2004 11:27:15 -0600 (MDT) Original-To: "Stefan Monnier" , "Juri Linkov" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-reply-to: <877jwqfmjb.fsf-monnier+emacs@alfajor.local> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:21387 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21387 Forgive me if this is not too germane or up-to-date. To me, it makes sense for `switch-to-buffer' to use another window if the selected window is dedicated. FWIW, here's the redefinition of `switch-to-buffer' that I use (Emacs 20 - sorry): ;; 1) Uses `read-buffer' in interactive spec. ;; 2) If current window is dedicated, then use another window. ;; NOTE: Emacs versions >= 19.34 signal an error if dedicated window, ;; instead of using another one. Don't know what the 19.28 version did. ;; 3) `fit-frame-if-one-window' if `fit-frame-when-switch-to-p'. (defun switch-to-buffer (buffer &optional norecord) "Select buffer BUFFER in current window, unless the window is dedicated. If current window is dedicated (`window-dedicated-p'), then another window is used. BUFFER may be a buffer or its name. Optional second arg NORECORD non-nil => Do not put BUFFER at front of list of recently selected buffers. *WARNING*: This is NOT the way to work on another buffer temporarily within a Lisp program! Use `set-buffer' instead, to avoid messing with window-buffer correspondences. `fit-frame-if-one-window' if `fit-frame-when-switch-to-p'." (interactive (list (read-buffer "Switch to buffer: " nil 'existing))) (if (window-dedicated-p (selected-window)) (switch-to-buffer-other-window buffer) (old-switch-to-buffer buffer norecord)) (fit-frame-if-one-window-and-cond fit-frame-when-switch-to-p)) [FYI - Function `fit-frame-if-one-window-and-cond' shrink-wraps the frame of the selected window if variable (user option) `fit-frame-when-switch-to-p' is non-nil. Function `read-buffer' reads the name of a buffer and returns it as a string. Prompts with first arg, PROMPT (a string). The default buffer is named by the optional 2nd arg, DEFAULT, if a string or buffer, or by `another-buffer' if nil. Non-nil optional 3rd arg, EXISTING, means to allow only names of existing buffers.] - Drew -----Original Message----- From: emacs-devel-bounces+drew.adams=oracle.com@gnu.org [mailto:emacs-devel-bounces+drew.adams=oracle.com@gnu.org]On Behalf Of Stefan Monnier Sent: Thursday, April 08, 2004 9:47 AM To: Juri Linkov Cc: emacs-devel@gnu.org Subject: Re: Jumping to C source from *Help* > - (pop-to-buffer (car location)) > + (switch-to-buffer (car location)) That signals an error when the *Help* buffer is on a dedicated window (as is the case for me). I spend a lot of time getting rid of such misuses of switch-to-buffer, so I strongly oppose this patch. Of course, the right way to fix it might be to make switch-to-buffer delegate to pop-to-buffer rather than signal an error. But last time I suggested it, Richard did not like it. Stefan