+2011-01-11 Martin Rudalics <rudalics@gmx.at>
+
+ * buff-menu.el (Buffer-menu-mode-map): Bind "q" to
+ quit-restore-window.
+ (buffer-menu): Call pop-to-buffer-same-window.
+ (buffer-menu-other-window): Call pop-to-buffer-other-window.
+ (Buffer-menu-select): Rewrite using display-buffer-same-window
+ and display-buffer.
+ (Buffer-menu-1-window, Buffer-menu-mouse-select)
+ (Buffer-menu-this-window): Call pop-to-buffer-same-window.
+ (Buffer-menu-other-window): Call pop-to-buffer-other-window.
+ (Buffer-menu-switch-other-window): Call
+ display-buffer-same-frame-other-window.
+ (Buffer-menu-2-window): Add label argument in calls of
+ display-buffer-same-window and
+ pop-to-buffer-same-frame-other-window.
+
+ * mail/reporter.el (reporter-submit-bug-report): Use
+ display-buffer-same-frame-other-window.
+
+ * progmodes/compile.el (compilation-find-file): Use
+ display-buffer-same-frame.
+
+ * progmodes/inf-lisp.el (switch-to-lisp): Rewrite with new buffer
+ display method specifiers.
+
+ * vc/ediff-ptch.el (ediff-get-patch-buffer): Use
+ pop-to-buffer-other-window.
+ (ediff-patch-file-internal): Replace switch-to-buffer by
+ pop-to-buffer-same-window and switch-to-buffer-other-window by
+ pop-to-buffer-other-window.
+
+ * vc/pcvs.el (cvs-ediff-exit-hook): Call
+ pop-to-buffer-same-window instead of switch-to-buffer.
+ (cvs-mode-find-file): Replace switch-to-buffer and
+ switch-to-buffer-other-window by pop-to-buffer-same-window and
+ pop-to-buffer-other-window. Replace call to dired-other-window
+ by call to display-buffer-other-window.
+ (cvs-temp-buffer): Call display-buffer-other-window instead of
+ display-buffer.
+
+ * vc/pcvs-util.el (cvs-bury-buffer): Call quit-restore-window.
+
2011-01-09 Martin Rudalics <rudalics@gmx.at>
* dired.el (dired-pop-to-buffer): Call
;;; Code:
-;;Trying to preserve the old window configuration works well in
-;;simple scenarios, when you enter the buffer menu, use it, and exit it.
-;;But it does strange things when you switch back to the buffer list buffer
-;;with C-x b, later on, when the window configuration is different.
-;;The choice seems to be, either restore the window configuration
-;;in all cases, or in no cases.
-;;I decided it was better not to restore the window config at all. -- rms.
-
-;;But since then, I changed buffer-menu to use the selected window,
-;;so q now once again goes back to the previous window configuration.
-
-;;(defvar Buffer-menu-window-config nil
-;; "Window configuration saved from entry to `buffer-menu'.")
-
;; Put buffer *Buffer List* into proper mode right away
;; so that from now on even list-buffers is enough to get a buffer menu.
(define-key map (kbd "M-s a M-C-s") 'Buffer-menu-isearch-buffers-regexp)
(define-key map [menu-bar Buffer-menu-mode] (cons (purecopy "Buffer-Menu") menu-map))
(define-key menu-map [quit]
- `(menu-item ,(purecopy "Quit") quit-window
+ `(menu-item ,(purecopy "Quit") quit-restore-window
:help ,(purecopy "Remove the buffer menu from the display")))
(define-key menu-map [rev]
`(menu-item ,(purecopy "Refresh") revert-buffer
After this come the buffer name, its size in characters,
its major mode, and the visited file name (if any)."
(interactive "P")
-;;; (setq Buffer-menu-window-config (current-window-configuration))
- (switch-to-buffer (list-buffers-noselect arg))
+ (pop-to-buffer-same-window
+ (list-buffers-noselect arg) nil 'buffer-menu)
(message
"Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help."))
Type q to remove the buffer menu from the display.
For more information, see the function `buffer-menu'."
(interactive "P")
-;;; (setq Buffer-menu-window-config (current-window-configuration))
- (switch-to-buffer-other-window (list-buffers-noselect arg))
+ (pop-to-buffer-other-window
+ (list-buffers-noselect arg) nil 'buffer-menu-other-window)
(message
"Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help."))
(interactive)
(let ((buff (Buffer-menu-buffer t))
(menu (current-buffer))
- (others ())
- tem)
+ others tem buff-window)
(Buffer-menu-beginning)
(while (re-search-forward "^>" nil t)
(setq tem (Buffer-menu-buffer t))
(delete-char -1)
(insert ?\s))
(or (eq tem buff) (memq tem others) (setq others (cons tem others))))
- (setq others (nreverse others)
- tem (/ (1- (frame-height)) (1+ (length others))))
+ (setq others (nreverse others))
+ ;; Now start displaying the buffers.
(delete-other-windows)
- (switch-to-buffer buff)
- (or (eq menu buff)
- (bury-buffer menu))
- (if (equal (length others) 0)
- (progn
-;;; ;; Restore previous window configuration before displaying
-;;; ;; selected buffers.
-;;; (if Buffer-menu-window-config
-;;; (progn
-;;; (set-window-configuration Buffer-menu-window-config)
-;;; (setq Buffer-menu-window-config nil)))
- (switch-to-buffer buff))
- (while others
- (split-window nil tem)
- (other-window 1)
- (switch-to-buffer (car others))
- (setq others (cdr others)))
- (other-window 1) ;back to the beginning!
-)))
+ (setq buff-window (display-buffer-same-window
+ buff 'Buffer-menu-select-buff))
+ (unless (eq menu buff)
+ (bury-buffer menu))
+ (when others
+ ;; Never rebind `window-splits' to anything but 'binary ...
+ (let ((window-splits 'resize)
+ (window buff-window)
+ other)
+ (while (and window others)
+ (setq other (car others))
+ ;; Try to always split the last window, so we get them in the
+ ;; appropriate order. This will fail when the frame is full,
+ ;; which means that the user has marked too many buffers.
+ (setq window (display-buffer
+ other `((pop-up-window (,window . below)))
+ 'Buffer-menu-select-other))
+ (setq others (cdr others)))))))
(defun Buffer-menu-marked-buffers ()
"Return a list of buffers marked with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command."
(defun Buffer-menu-1-window ()
"Select this line's buffer, alone, in full frame."
(interactive)
- (switch-to-buffer (Buffer-menu-buffer t))
- (bury-buffer (other-buffer))
- (delete-other-windows))
+ (let ((menu (current-buffer)))
+ (pop-to-buffer-same-window
+ (Buffer-menu-buffer t) nil 'buffer-menu-1-window)
+ (bury-buffer menu)
+ (delete-other-windows)))
(defun Buffer-menu-mouse-select (event)
"Select the buffer whose line you click on."
(goto-char (posn-point (event-end event)))
(setq buffer (Buffer-menu-buffer t))))
(select-window (posn-window (event-end event)))
- (if (and (window-dedicated-p (selected-window))
- (eq (selected-window) (frame-root-window)))
- (switch-to-buffer-other-frame buffer)
- (switch-to-buffer buffer))))
+ (pop-to-buffer-same-window buffer nil 'Buffer-menu-mouse-select)))
(defun Buffer-menu-this-window ()
"Select this line's buffer in this window."
(interactive)
- (switch-to-buffer (Buffer-menu-buffer t)))
+ (pop-to-buffer-same-window
+ (Buffer-menu-buffer t) nil 'Buffer-menu-this-window))
(defun Buffer-menu-other-window ()
"Select this line's buffer in other window, leaving buffer menu visible."
(interactive)
- (switch-to-buffer-other-window (Buffer-menu-buffer t)))
+ (pop-to-buffer-other-window
+ (Buffer-menu-buffer t) nil 'Buffer-menu-other-window))
+;; Name and doc-string of this function are confusing.
(defun Buffer-menu-switch-other-window ()
"Make the other window select this line's buffer.
The current window remains selected."
(interactive)
- (display-buffer-same-frame-other-window (Buffer-menu-buffer t)))
+ (display-buffer-same-frame-other-window
+ ;; Maybe we should insist on reusing another window here.
+ (Buffer-menu-buffer t) 'Buffer-menu-switch-other-window))
(defun Buffer-menu-2-window ()
"Select this line's buffer, with previous buffer in second window."
(let ((buff (Buffer-menu-buffer t))
(menu (current-buffer)))
(delete-other-windows)
- (display-buffer-same-window (other-buffer))
- (pop-to-buffer-same-frame-other-window buff)
+ ;; It's very difficult to understand where we want to display what.
+ (display-buffer-same-window
+ (other-buffer) 'Buffer-menu-2-window-first)
+ (pop-to-buffer-same-frame-other-window
+ buff 'Buffer-menu-2-window-second)
(bury-buffer menu)))
(defun Buffer-menu-toggle-read-only ()
;; Strangely, if no window is created, `display-buffer' ends up
;; doing a `switch-to-buffer' which does a `set-buffer', hence
;; the need for `save-excursion'.
- (unless nosetup (save-excursion (display-buffer buf)))
+ (unless nosetup (save-excursion
+ (display-buffer-other-window buf)))
;; FIXME: this doesn't do the right thing if the user later on
;; does a `find-file-other-window' and `scroll-other-window'
(set (make-local-variable 'other-window-scroll-buffer) buf))
;; switch back to the *cvs* buffer
(when (and cvs-buf (buffer-live-p cvs-buf)
(not (get-buffer-window cvs-buf t)))
- (ignore-errors (switch-to-buffer cvs-buf))))
+ (ignore-errors (pop-to-buffer-same-window cvs-buf))))
(defun cvs-ediff-diff (b1 b2)
(let ((ediff-after-quit-destination-buffer (current-buffer))
(string-to-number (match-string 1))
1)))
-
+;; Someone should explain what these arguments are.
(defun cvs-mode-find-file (e &optional other view)
"Select a buffer containing the file.
With a prefix, opens the buffer in an OTHER window."
(cvs-expand-dir-name (cvs-fileinfo->dir fi)))
(cond ((eq other 'dont-select)
(display-buffer (find-file-noselect default-directory)))
- (other (dired-other-window default-directory))
+ (other (display-buffer-other-window default-directory))
(t (dired default-directory)))
(set-buffer cvs-buf)
(setq default-directory odir))
(find-file-noselect (cvs-fileinfo->full-name fi)))))
(funcall (cond ((eq other 'dont-select) 'display-buffer)
(other
- (if view 'view-buffer-other-window
- 'switch-to-buffer-other-window))
- (t (if view 'view-buffer 'switch-to-buffer)))
+ (if view
+ 'view-buffer-other-window
+ 'pop-to-buffer-other-window))
+ (t (if view
+ 'view-buffer
+ 'pop-to-buffer-same-window)))
buf)
(when (and cvs-find-file-and-jump (cvs-applicable-p fi 'diff-base))
(save-restriction