unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jürgen Hartmann" <juergen_hartmann_@hotmail.com>
To: 20861@debbugs.gnu.org
Subject: bug#20861: 24.4/5; [PATCH] Consistency of switch-to-visible-buffer
Date: Sat, 20 Jun 2015 22:34:26 +0200	[thread overview]
Message-ID: <DUB124-W1994DAF58D6FEE234B7C07A8A30@phx.gbl> (raw)

This patch is based on an idea of Martin Rudalics who also suggested to send
it as a bug report:

   http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/msg00228.html
   http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/msg00291.html

The problem was discussed on help-gnu-emacs--

   http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/msg00135.html

--and can be summarized like this:

In accordance to the documentation of the variable switch-to-visible-buffer,
the commands switch-to-prev-buffer and switch-to-next-buffer switch to an
already visible buffer only if switch-to-visible-buffer is non-nil _and_ if
that buffer was already shown before in the respective window. The latter
condition is an obstacle if one wants to use these commands to quickly cycle
a window through all existing buffers.

To illustrate that in great detail:

   * Open an Emacs session via

        emacs -Q

   * Split window by means of C-x 2.

   * Use C-x b to generate a new buffer and name it A.

   * Select the other window via C-x o.

   * Use C-x b to generate a new buffer and name it B.

   * Repetitively switch buffers using C-x <left> which is bound to
     previous-buffer, noticing that this never switches to buffer A.

NB: switch-to-visible-buffer is bound to t.

The patch below alters this behavior, such that the repetitive switching of
buffers in the example will include buffer A in spite the fact that it was
never shown before in the current window. So it will be easier for example to
get buffer A shown in both windows or to swap the buffers A and B between the
windows.

Only the file

   lisp/window.el

is affected by the patch and therein only the definitions of

   switch-to-visible-buffer
   switch-to-prev-buffer
   switch-to-next-buffer

Since there were only minor changes in window.el between Emacs 24.4 and 24.5
the patch should perfectly apply to both of these versions of Emacs. However
it was build and tested on Emacs 24.4 only.

Proposal for a change log entry:

   * lisp/window.el (switch-to-visible-buffer): Doc adjustment.
     (switch-to-prev-buffer, switch-to-next-buffer): Respect
     switch-to-visible-buffer independent of the windows history.

Patch:

diff -rcN emacs-24.4_original/lisp/window.el emacs-24.4_changed/lisp/window.el
*** emacs-24.4_original/lisp/window.el    2014-09-30 17:27:41.000000000 +0200
--- emacs-24.4_changed/lisp/window.el    2015-06-20 18:52:24.815266436 +0200
***************
*** 3648,3659 ****
  (defcustom switch-to-visible-buffer t
    "If non-nil, allow switching to an already visible buffer.
  If this variable is non-nil, `switch-to-prev-buffer' and
! `switch-to-next-buffer' may switch to an already visible buffer
! provided the buffer was shown before in the window specified as
! argument to those functions.  If this variable is nil,
! `switch-to-prev-buffer' and `switch-to-next-buffer' always try to
! avoid switching to a buffer that is already visible in another
! window on the same frame."
    :type 'boolean
    :version "24.1"
    :group 'windows)
--- 3648,3657 ----
  (defcustom switch-to-visible-buffer t
    "If non-nil, allow switching to an already visible buffer.
  If this variable is non-nil, `switch-to-prev-buffer' and
! `switch-to-next-buffer' may switch to an already visible buffer.
! If this variable is nil, `switch-to-prev-buffer' and
! `switch-to-next-buffer' always try to avoid switching to a buffer
! that is already visible in another window on the same frame."
    :type 'boolean
    :version "24.1"
    :group 'windows)
***************
*** 3724,3730 ****
                     (or (null pred) (funcall pred buffer))
             (not (eq (aref (buffer-name buffer) 0) ?\s))
             (or bury-or-kill (not (memq buffer next-buffers))))
!       (if (get-buffer-window buffer frame)
            ;; Try to avoid showing a buffer visible in some other window.
            (unless visible
          (setq visible buffer))
--- 3722,3729 ----
                     (or (null pred) (funcall pred buffer))
             (not (eq (aref (buffer-name buffer) 0) ?\s))
             (or bury-or-kill (not (memq buffer next-buffers))))
!       (if (and (not switch-to-visible-buffer)
!            (get-buffer-window buffer frame))
            ;; Try to avoid showing a buffer visible in some other window.
            (unless visible
          (setq visible buffer))
***************
*** 3826,3832 ****
                     (or (null pred) (funcall pred buffer))
             (not (eq (aref (buffer-name buffer) 0) ?\s))
             (not (assq buffer (window-prev-buffers window))))
!       (if (get-buffer-window buffer frame)
            ;; Try to avoid showing a buffer visible in some other window.
            (setq visible buffer)
          (setq new-buffer buffer)
--- 3825,3832 ----
                     (or (null pred) (funcall pred buffer))
             (not (eq (aref (buffer-name buffer) 0) ?\s))
             (not (assq buffer (window-prev-buffers window))))
!       (if (and (not switch-to-visible-buffer)
!            (get-buffer-window buffer frame))
            ;; Try to avoid showing a buffer visible in some other window.
            (setq visible buffer)
          (setq new-buffer buffer)

Juergen

 		 	   		  




             reply	other threads:[~2015-06-20 20:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-20 20:34 Jürgen Hartmann [this message]
2015-06-22  8:49 ` bug#20861: 24.4/5; [PATCH] Consistency of switch-to-visible-buffer martin rudalics
2015-06-22 10:01   ` Jürgen Hartmann
2015-06-23 15:59     ` martin rudalics

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=DUB124-W1994DAF58D6FEE234B7C07A8A30@phx.gbl \
    --to=juergen_hartmann_@hotmail.com \
    --cc=20861@debbugs.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).