[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8911: bs-cycle-next deletes window in some cases.

From: Juanma Barranquero
Subject: bug#8911: bs-cycle-next deletes window in some cases.
Date: Mon, 27 Jun 2011 22:11:52 +0200

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 same nil nil)
        (reuse-window-dedicated . t)
        (override . t))

to their .emacs.

OK to install?


=== 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)))
 (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 @@
             (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"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]