From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#8911: bs-cycle-next deletes window in some cases. Date: Mon, 27 Jun 2011 22:11:52 +0200 Message-ID: References: <4E009EB0.1050903@gmx.at> <181538AC4C8B4765A99060E0425B9AB5@us.oracle.com> <9170F33E41584E0B8D96DD5EFC84599E@us.oracle.com> <8E864413162C4814BE8EFFD0C1FA1989@us.oracle.com> <4E06FBF8.9040205@gmx.at> <4E082AA8.3010807@gmx.at> <4E087B9B.8070608@gmx.at> <4E088FB8.6010004@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: dough.gmane.org 1309207791 12810 80.91.229.12 (27 Jun 2011 20:49:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 27 Jun 2011 20:49:51 +0000 (UTC) Cc: 8911@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 27 22:49:45 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QbIka-0002BP-Mv for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Jun 2011 22:49:44 +0200 Original-Received: from localhost ([::1]:59958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbIkZ-0006OR-GC for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Jun 2011 16:49:43 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:44825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbIB7-0005zH-HU for bug-gnu-emacs@gnu.org; Mon, 27 Jun 2011 16:13:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QbIB5-0006KR-Tv for bug-gnu-emacs@gnu.org; Mon, 27 Jun 2011 16:13:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbIB5-0006KF-HS for bug-gnu-emacs@gnu.org; Mon, 27 Jun 2011 16:13:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QbIB4-0006YB-Iz; Mon, 27 Jun 2011 16:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Jun 2011 20:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8911 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8911-submit@debbugs.gnu.org id=B8911.130920556325144 (code B ref 8911); Mon, 27 Jun 2011 20:13:02 +0000 Original-Received: (at 8911) by debbugs.gnu.org; 27 Jun 2011 20:12:43 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QbIAk-0006XU-DK for submit@debbugs.gnu.org; Mon, 27 Jun 2011 16:12:42 -0400 Original-Received: from mail-pz0-f42.google.com ([209.85.210.42]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QbIAh-0006XH-8X for 8911@debbugs.gnu.org; Mon, 27 Jun 2011 16:12:40 -0400 Original-Received: by pzk37 with SMTP id 37so3540077pzk.29 for <8911@debbugs.gnu.org>; Mon, 27 Jun 2011 13:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=ZKSlc/Oc6RjYVza9H0rybw00cbl5bT8aqcpHZB3oTJo=; b=wjz59n6NhT4hSQuS0x8fWU74JfwDYSobWs9ey4Hyv1wNvv5V3Dv1d0LzgZ1Vn/WaTz jOFXq91rt2iv7pHEb/YvcueJo4bWgdzv2P2blZnhFp9bQxxH56AvIG5EIuXe81hE2kCM zMKdwR2hVgIakkmfmWdFZV73l64B+5RLTaLiE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=x6AMR+LEXgMSc03f/CJ82srJU161Nt6NgQB0Gjxk1cmL26obCIgWnU8/XaoiuLFtEE O/jlvxSwXLa4miIWNZzu2b8b5Qa4j1y2wembItXC402aLvcSZ3XpKRmM/jR9Xi9VEhXh E6SMNWR9o1+w70AKeGkYuolTreAaOKOGGnJrI= Original-Received: by 10.142.54.3 with SMTP id c3mr1268127wfa.221.1309205553112; Mon, 27 Jun 2011 13:12:33 -0700 (PDT) Original-Received: by 10.142.50.7 with HTTP; Mon, 27 Jun 2011 13:11:52 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 27 Jun 2011 16:13:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:47543 Archived-At: This code, which is mostly Martin's, fixes case 2. The user can override the "signal error" behavior by customizing display-buffer-alist or adding (push '(((label . bs-cycle-next) (label . bs-cycle-previous)) reuse-window (reuse-window same nil nil) (reuse-window-dedicated . t) (override . t)) display-buffer-alist) to their .emacs. OK to install? J === modified file 'lisp/bs.el' --- lisp/bs.el 2011-06-27 01:52:37 +0000 +++ lisp/bs.el 2011-06-27 19:59:41 +0000 @@ -1190,6 +1190,15 @@ (defvar bs--cycle-list nil "Current buffer list used for cycling.") +(defun bs--reuse-window-unless-dedicated (buffer &rest _args) + "Display BUFFER in the selected window. +If the selected window is dedicated, signal an error instead. +This function is intended to be called from `display-buffer'. +To override it, see `display-buffer-alist'." + (if (and (window-dedicated-p) (not (eq (window-buffer) buffer))) + (error "Selected window is dedicated to its buffer") + (display-buffer-same-window buffer))) + ;;;###autoload (defun bs-cycle-next () "Select next buffer defined by buffer cycling. @@ -1215,7 +1224,9 @@ ;; We don't want the frame iconified if the only window in the frame ;; happens to be dedicated. (bury-buffer (current-buffer)) - (switch-to-buffer next) + (display-buffer next + '((fun-with-args bs--reuse-window-unless-dedicated)) + 'bs-cycle-next) (setq bs--cycle-list (append (cdr cycle-list) (list (car cycle-list)))) (bs-message-without-log "Next buffers: %s" @@ -1244,7 +1255,9 @@ bs--cycle-list))) (prev-buffer (car tupel)) (cycle-list (cdr tupel))) - (switch-to-buffer prev-buffer) + (display-buffer prev-buffer + '((fun-with-args bs--reuse-window-unless-dedicated)) + 'bs-cycle-previous) (setq bs--cycle-list (append (last cycle-list) (reverse (cdr (reverse cycle-list))))) (bs-message-without-log "Previous buffers: %s"