From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?J=C3=BCrgen?= Hartmann Newsgroups: gmane.emacs.bugs Subject: bug#20861: 24.4/5; [PATCH] Consistency of switch-to-visible-buffer Date: Sat, 20 Jun 2015 22:34:26 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1434832525 21226 80.91.229.3 (20 Jun 2015 20:35:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Jun 2015 20:35:25 +0000 (UTC) To: 20861@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 20 22:35:13 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z6PTs-00045w-El for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Jun 2015 22:35:12 +0200 Original-Received: from localhost ([::1]:34631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6PTr-0004OB-Jg for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Jun 2015 16:35:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6PTn-0004My-NW for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2015 16:35:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z6PTk-0004n1-BL for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2015 16:35:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6PTk-0004mL-7x for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2015 16:35:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z6PTj-0005dn-OS for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2015 16:35:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?J=C3=BCrgen?= Hartmann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Jun 2015 20:35:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 20861 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" Original-Received: via spool by submit@debbugs.gnu.org id=B.143483248521652 (code B ref -1); Sat, 20 Jun 2015 20:35:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Jun 2015 20:34:45 +0000 Original-Received: from localhost ([127.0.0.1]:52954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z6PTP-0005d8-L3 for submit@debbugs.gnu.org; Sat, 20 Jun 2015 16:34:44 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57128) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z6PTM-0005ce-CV for submit@debbugs.gnu.org; Sat, 20 Jun 2015 16:34:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z6PTG-0004Vx-0T for submit@debbugs.gnu.org; Sat, 20 Jun 2015 16:34:35 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:50640) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6PTF-0004Vo-Ti for submit@debbugs.gnu.org; Sat, 20 Jun 2015 16:34:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6PTE-0004FI-Ek for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2015 16:34:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z6PTA-0004TP-65 for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2015 16:34:32 -0400 Original-Received: from dub004-omc1s23.hotmail.com ([157.55.0.222]:56139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6PT9-0004Sx-Tm for bug-gnu-emacs@gnu.org; Sat, 20 Jun 2015 16:34:28 -0400 Original-Received: from DUB124-W19 ([157.55.0.237]) by DUB004-OMC1S23.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Sat, 20 Jun 2015 13:34:26 -0700 X-TMN: [vJdMKOPiGTi94mtdPuatK7M5K2zFENTh] X-Originating-Email: [juergen_hartmann_@hotmail.com] Importance: Normal X-OriginalArrivalTime: 20 Jun 2015 20:34:26.0616 (UTC) FILETIME=[8017B380:01D0AB98] X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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:104161 Archived-At: This patch is based on an idea of Martin Rudalics who also suggested to sen= d=0A= it as a bug report:=0A= =0A= =A0=A0 http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/msg00228.ht= ml=0A= =A0=A0 http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/msg00291.ht= ml=0A= =0A= The problem was discussed on help-gnu-emacs--=0A= =0A= =A0=A0 http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/msg00135.ht= ml=0A= =0A= --and can be summarized like this:=0A= =0A= In accordance to the documentation of the variable switch-to-visible-buffer= =2C=0A= the commands switch-to-prev-buffer and switch-to-next-buffer switch to an= =0A= already visible buffer only if switch-to-visible-buffer is non-nil _and_ if= =0A= that buffer was already shown before in the respective window. The latter= =0A= condition is an obstacle if one wants to use these commands to quickly cycl= e=0A= a window through all existing buffers.=0A= =0A= To illustrate that in great detail:=0A= =0A= =A0=A0 * Open an Emacs session via=0A= =0A= =A0=A0=A0=A0=A0=A0=A0 emacs -Q=0A= =0A= =A0=A0 * Split window by means of C-x 2.=0A= =0A= =A0=A0 * Use C-x b to generate a new buffer and name it A.=0A= =0A= =A0=A0 * Select the other window via C-x o.=0A= =0A= =A0=A0 * Use C-x b to generate a new buffer and name it B.=0A= =0A= =A0=A0 * Repetitively switch buffers using C-x which is bound to=0A= =A0=A0=A0=A0 previous-buffer=2C noticing that this never switches to buffer= A.=0A= =0A= NB: switch-to-visible-buffer is bound to t.=0A= =0A= The patch below alters this behavior=2C such that the repetitive switching = of=0A= buffers in the example will include buffer A in spite the fact that it was= =0A= never shown before in the current window. So it will be easier for example = to=0A= get buffer A shown in both windows or to swap the buffers A and B between t= he=0A= windows.=0A= =0A= Only the file=0A= =0A= =A0=A0 lisp/window.el=0A= =0A= is affected by the patch and therein only the definitions of=0A= =0A= =A0=A0 switch-to-visible-buffer=0A= =A0=A0 switch-to-prev-buffer=0A= =A0=A0 switch-to-next-buffer=0A= =0A= Since there were only minor changes in window.el between Emacs 24.4 and 24.= 5=0A= the patch should perfectly apply to both of these versions of Emacs. Howeve= r=0A= it was build and tested on Emacs 24.4 only.=0A= =0A= Proposal for a change log entry:=0A= =0A= =A0=A0 * lisp/window.el (switch-to-visible-buffer): Doc adjustment.=0A= =A0=A0=A0=A0 (switch-to-prev-buffer=2C switch-to-next-buffer): Respect=0A= =A0=A0=A0=A0 switch-to-visible-buffer independent of the windows history.= =0A= =0A= Patch:=0A= =0A= diff -rcN emacs-24.4_original/lisp/window.el emacs-24.4_changed/lisp/window= .el=0A= *** emacs-24.4_original/lisp/window.el=A0=A0=A0 2014-09-30 17:27:41.0000000= 00 +0200=0A= --- emacs-24.4_changed/lisp/window.el=A0=A0=A0 2015-06-20 18:52:24.81526643= 6 +0200=0A= ***************=0A= *** 3648=2C3659 ****=0A= =A0 (defcustom switch-to-visible-buffer t=0A= =A0=A0=A0 "If non-nil=2C allow switching to an already visible buffer.=0A= =A0 If this variable is non-nil=2C `switch-to-prev-buffer' and=0A= ! `switch-to-next-buffer' may switch to an already visible buffer=0A= ! provided the buffer was shown before in the window specified as=0A= ! argument to those functions.=A0 If this variable is nil=2C=0A= ! `switch-to-prev-buffer' and `switch-to-next-buffer' always try to=0A= ! avoid switching to a buffer that is already visible in another=0A= ! window on the same frame."=0A= =A0=A0=A0 :type 'boolean=0A= =A0=A0=A0 :version "24.1"=0A= =A0=A0=A0 :group 'windows)=0A= --- 3648=2C3657 ----=0A= =A0 (defcustom switch-to-visible-buffer t=0A= =A0=A0=A0 "If non-nil=2C allow switching to an already visible buffer.=0A= =A0 If this variable is non-nil=2C `switch-to-prev-buffer' and=0A= ! `switch-to-next-buffer' may switch to an already visible buffer.=0A= ! If this variable is nil=2C `switch-to-prev-buffer' and=0A= ! `switch-to-next-buffer' always try to avoid switching to a buffer=0A= ! that is already visible in another window on the same frame."=0A= =A0=A0=A0 :type 'boolean=0A= =A0=A0=A0 :version "24.1"=0A= =A0=A0=A0 :group 'windows)=0A= ***************=0A= *** 3724=2C3730 ****=0A= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (or (null pred= ) (funcall pred buffer))=0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (not (eq (aref (buffer-name buffer) 0) ?\s))= =0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (or bury-or-kill (not (memq buffer next-buff= ers))))=0A= ! =A0=A0=A0 =A0 (if (get-buffer-window buffer frame)=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 =3B=3B Try to avoid showing a buffer visible = in some other window.=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 (unless visible=0A= =A0 =A0=A0=A0 =A0=A0=A0 (setq visible buffer))=0A= --- 3722=2C3729 ----=0A= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (or (null pred= ) (funcall pred buffer))=0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (not (eq (aref (buffer-name buffer) 0) ?\s))= =0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (or bury-or-kill (not (memq buffer next-buff= ers))))=0A= ! =A0=A0=A0 =A0 (if (and (not switch-to-visible-buffer)=0A= ! =A0=A0=A0 =A0=A0=A0 =A0=A0 (get-buffer-window buffer frame))=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 =3B=3B Try to avoid showing a buffer visible = in some other window.=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 (unless visible=0A= =A0 =A0=A0=A0 =A0=A0=A0 (setq visible buffer))=0A= ***************=0A= *** 3826=2C3832 ****=0A= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (or (null pred= ) (funcall pred buffer))=0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (not (eq (aref (buffer-name buffer) 0) ?\s))= =0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (not (assq buffer (window-prev-buffers windo= w))))=0A= ! =A0=A0=A0 =A0 (if (get-buffer-window buffer frame)=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 =3B=3B Try to avoid showing a buffer visible = in some other window.=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 (setq visible buffer)=0A= =A0 =A0=A0=A0 =A0=A0=A0 (setq new-buffer buffer)=0A= --- 3825=2C3832 ----=0A= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (or (null pred= ) (funcall pred buffer))=0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (not (eq (aref (buffer-name buffer) 0) ?\s))= =0A= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (not (assq buffer (window-prev-buffers windo= w))))=0A= ! =A0=A0=A0 =A0 (if (and (not switch-to-visible-buffer)=0A= ! =A0=A0=A0 =A0=A0=A0 =A0=A0 (get-buffer-window buffer frame))=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 =3B=3B Try to avoid showing a buffer visible = in some other window.=0A= =A0 =A0=A0=A0 =A0=A0=A0=A0=A0 (setq visible buffer)=0A= =A0 =A0=A0=A0 =A0=A0=A0 (setq new-buffer buffer)=0A= =0A= Juergen=0A= =0A= =