unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alp Aker <alptekin.aker@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: 12081@debbugs.gnu.org
Subject: bug#12081: 24.1; buffer-predicate often not called
Date: Tue, 31 Jul 2012 02:59:08 -0400	[thread overview]
Message-ID: <CACxch4rO30GvVy2nN9cfx0nK51k+xavxBePmRRUsU+Zue0dPkA@mail.gmail.com> (raw)
In-Reply-To: <5016C790.1030406@gmx.at>

On Mon, Jul 30, 2012 at 1:42 PM, martin rudalics <rudalics@gmx.at> wrote:
> When `replace-buffer-in-windows' fails to replace the buffer,
> replace_buffer_in_windows_safely will kick in and automatically do what
> you mean.

Yes, I realized that about kill_buffer; my concern was whether other
users of replace-buffer-in-windows should need to provide fallback
behavior.  I'll defer to your judgment :)

So, would something like the following patch be ok (after adding
appropriate documentation changes)?  Note that with these changes,
there might still be some potentially odd behavior.  Here's a
contrived example.  From Emacs -Q, evaluating the following in
*scratch*:

(progn
  (set-frame-parameter nil 'buffer-predicate (lambda (x) nil))
  (switch-to-buffer (get-buffer-create "foo"))
  (switch-to-prev-buffer))

will leave buffer "foo" displayed in the selected window, but the
return value of of `switch-to-prev-buffer' will be #<buffer
*scratch*>, because `next-buffer' was assigned during the scan of the
previous buffers even though we did not switch to it.  Is such a
misleading return value ok?  (I realize this could be a considered a
variant of my earlier concern, which you argued was misplaced, but I
thought I should mention it nonetheless.)


=== modified file 'lisp/window.el'
--- lisp/window.el	2012-07-18 10:02:54 +0000
+++ lisp/window.el	2012-07-31 03:10:31 +0000
@@ -2679,6 +2679,7 @@
 	 (old-buffer (window-buffer window))
 	 ;; Save this since it's destroyed by `set-window-buffer'.
 	 (next-buffers (window-next-buffers window))
+         (pred (frame-parameter frame 'buffer-predicate))
 	 entry new-buffer killed-buffers visible)
     (when (window-dedicated-p window)
       (error "Window %s is dedicated to buffer %s" window old-buffer))
@@ -2692,6 +2693,7 @@
 		       (not (setq killed-buffers
 				  (cons new-buffer killed-buffers))))
 		   (not (eq new-buffer old-buffer))
+                   (or (null pred) (funcall pred new-buffer))
                    (or bury-or-kill
 		       (not (memq new-buffer next-buffers))))
 	  (if (and (not switch-to-visible-buffer)
@@ -2713,6 +2715,7 @@
 	(when (and (buffer-live-p buffer)
 		   (not (eq buffer old-buffer))
 		   (not (eq (aref (buffer-name buffer) 0) ?\s))
+                   (or (null pred) (funcall pred buffer))
 		   (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.
@@ -2731,6 +2734,7 @@
 			 (not (setq killed-buffers
 				    (cons buffer killed-buffers))))
 		     (not (eq buffer old-buffer))
+                     (or (null pred) (funcall pred buffer))
 		     (setq entry (assq buffer (window-prev-buffers window))))
 	    (setq new-buffer buffer)
 	    (set-window-buffer-start-and-point
@@ -2773,6 +2777,7 @@
 	 (frame (window-frame window))
 	 (old-buffer (window-buffer window))
 	 (next-buffers (window-next-buffers window))
+         (pred (frame-parameter frame 'buffer-predicate))
 	 new-buffer entry killed-buffers visible)
     (when (window-dedicated-p window)
       (error "Window %s is dedicated to buffer %s" window old-buffer))
@@ -2784,6 +2789,7 @@
 		       (not (setq killed-buffers
 				  (cons buffer killed-buffers))))
 		   (not (eq buffer old-buffer))
+                   (or (null pred) (funcall pred buffer))
 		   (setq entry (assq buffer (window-prev-buffers window))))
 	  (setq new-buffer buffer)
 	  (set-window-buffer-start-and-point
@@ -2794,6 +2800,7 @@
       (dolist (buffer (buffer-list frame))
 	(when (and (buffer-live-p buffer) (not (eq buffer old-buffer))
 		   (not (eq (aref (buffer-name buffer) 0) ?\s))
+                   (or (null pred) (funcall pred buffer))
 		   (not (assq buffer (window-prev-buffers window))))
 	  (if (get-buffer-window buffer frame)
 	      ;; Try to avoid showing a buffer visible in some other window.
@@ -2808,6 +2815,7 @@
 		   (or (buffer-live-p new-buffer)
 		       (not (setq killed-buffers
 				  (cons new-buffer killed-buffers))))
+                   (or (null pred) (funcall pred new-buffer))
 		   (not (eq new-buffer old-buffer)))
 	  (if (and (not switch-to-visible-buffer)
 		   (get-buffer-window new-buffer frame))





  reply	other threads:[~2012-07-31  6:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-28 20:47 bug#12081: 24.1; buffer-predicate often not called Dave Abrahams
2012-07-29 13:56 ` martin rudalics
2012-07-29 15:05   ` Dave Abrahams
2012-07-29 17:08     ` martin rudalics
2012-07-29 17:31       ` Alp Aker
2012-07-29 18:24         ` Dave Abrahams
2012-07-29 21:37         ` Dave Abrahams
2012-07-29 23:30           ` Alp Aker
2012-07-29 23:53             ` Dave Abrahams
2012-07-30  9:13         ` martin rudalics
2012-07-30  9:35           ` Dave Abrahams
2012-07-30 17:42             ` martin rudalics
2012-07-30 20:13               ` Dave Abrahams
2012-07-31  8:39                 ` martin rudalics
2012-08-13 22:13                   ` Dave Abrahams
2012-08-14  9:09                     ` martin rudalics
2012-08-14 16:07                       ` Dave Abrahams
2012-07-30 16:22           ` Alp Aker
2012-07-30 16:33             ` Alp Aker
2012-07-30 17:42               ` martin rudalics
2012-07-31  6:59                 ` Alp Aker [this message]
2012-07-31  8:40                   ` martin rudalics
2012-08-31 17:15                   ` martin rudalics
2012-09-05 14:30                     ` martin rudalics
2012-07-30 17:42             ` 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=CACxch4rO30GvVy2nN9cfx0nK51k+xavxBePmRRUsU+Zue0dPkA@mail.gmail.com \
    --to=alptekin.aker@gmail.com \
    --cc=12081@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /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).