Commit f4f45fc5 authored by Martin Rudalics's avatar Martin Rudalics
Browse files

(quit-window): Restore delete window with second

arg non-nil behavior as of before 2008-10-30 change.
parent d7dbaa7d
2008-11-15 Martin Rudalics <rudalics@gmx.at>
* window.el (quit-window): Restore delete window with second
arg non-nil behavior as of before 2008-10-30 change.
2008-11-15 Chong Yidong <cyd@stupidchicken.com> 2008-11-15 Chong Yidong <cyd@stupidchicken.com>
   
* help-fns.el (describe-function-1): Do char-range check for * help-fns.el (describe-function-1): Do char-range check for
......
...@@ -241,15 +241,6 @@ meaning of this argument." ...@@ -241,15 +241,6 @@ meaning of this argument."
(walk-windows (lambda (w) (setq count (+ count 1))) (walk-windows (lambda (w) (setq count (+ count 1)))
minibuf) minibuf)
count)) count))
(defun window-safely-shrinkable-p (&optional window)
"Return t if WINDOW can be shrunk without shrinking other windows.
WINDOW defaults to the selected window."
(with-selected-window (or window (selected-window))
(let ((edges (window-edges)))
(or (= (nth 2 edges) (nth 2 (window-edges (previous-window))))
(= (nth 0 edges) (nth 0 (window-edges (next-window))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; `balance-windows' subroutines using `window-tree' ;;; `balance-windows' subroutines using `window-tree'
...@@ -1361,6 +1352,14 @@ Always return nil." ...@@ -1361,6 +1352,14 @@ Always return nil."
(enlarge-window 1) (enlarge-window 1)
(setq desired-height (1+ desired-height))))))) (setq desired-height (1+ desired-height)))))))
(defun window-safely-shrinkable-p (&optional window)
"Return t if WINDOW can be shrunk without shrinking other windows.
WINDOW defaults to the selected window."
(with-selected-window (or window (selected-window))
(let ((edges (window-edges)))
(or (= (nth 2 edges) (nth 2 (window-edges (previous-window))))
(= (nth 0 edges) (nth 0 (window-edges (next-window))))))))
(defun shrink-window-if-larger-than-buffer (&optional window) (defun shrink-window-if-larger-than-buffer (&optional window)
"Shrink height of WINDOW if its buffer doesn't need so many lines. "Shrink height of WINDOW if its buffer doesn't need so many lines.
More precisely, shrink WINDOW vertically to be as small as More precisely, shrink WINDOW vertically to be as small as
...@@ -1419,31 +1418,34 @@ Return non-nil if the window was shrunk, nil otherwise." ...@@ -1419,31 +1418,34 @@ Return non-nil if the window was shrunk, nil otherwise."
(error nil))))) (error nil)))))
(defun quit-window (&optional kill window) (defun quit-window (&optional kill window)
"Bury or kill (with KILL non-nil) the buffer displayed in WINDOW. "Quit WINDOW and bury its buffer.
With a prefix argument, kill the buffer instead. With a prefix argument, kill the buffer instead. WINDOW defaults
to the selected window.
KILL defaults to nil, WINDOW to the selected window. If WINDOW
is dedicated or a minibuffer window, delete it and, if it's the If WINDOW is non-nil, dedicated, or a minibuffer window, delete
only window on its frame, delete its frame as well provided there it and, if it's alone on its frame, its frame too. Otherwise, or
are other frames left. Otherwise, display some other buffer in if deleting WINDOW fails in any of the preceding cases, display
the window." another buffer in WINDOW using `switch-to-buffer'.
Optional argument KILL non-nil means kill WINDOW's buffer.
Otherwise, bury WINDOW's buffer, see `bury-buffer'."
(interactive "P") (interactive "P")
(let* ((window (or window (selected-window))) (let ((buffer (window-buffer window)))
(buffer (window-buffer window))) (if (or window
(if (or (window-minibuffer-p window) (window-dedicated-p window)) (window-minibuffer-p window)
(if (eq window (frame-root-window (window-frame window))) (window-dedicated-p window))
;; If this is the only window on its frame, try to delete the ;; WINDOW is either non-nil, a minibuffer window, or dedicated;
;; frame (`delete-windows-on' knows how to do that). ;; try to delete it.
(delete-windows-on buffer (selected-frame)) (let ((frame (window-frame (or window (selected-window)))))
;; Other windows are left, delete this window. But don't (if (eq window (frame-root-window frame))
;; throw an error if that fails for some reason. ;; WINDOW is alone on its frame. `delete-windows-on'
(condition-case nil ;; knows how to handle that case.
(delete-window window) (delete-windows-on buffer frame)
(error nil))) ;; There are other windows on its frame, delete WINDOW.
;; The window is neither dedicated nor a minibuffer window, (delete-window window)))
;; display another buffer in it. ;; Otherwise, switch to another buffer in the selected window.
(with-selected-window window (switch-to-buffer nil))
(switch-to-buffer (other-buffer))))
;; Deal with the buffer. ;; Deal with the buffer.
(if kill (if kill
(kill-buffer buffer) (kill-buffer buffer)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment