diff options
| author | Martin Rudalics | 2008-10-30 15:41:43 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2008-10-30 15:41:43 +0000 |
| commit | 9045be38cdbf47378af50b0cae7efdca04945ba9 (patch) | |
| tree | dc74373234badaf3485621e624b9deb2d79c9728 | |
| parent | 09c6e72e599a0ef7ec3b02441381d798fab0067b (diff) | |
| download | emacs-9045be38cdbf47378af50b0cae7efdca04945ba9.tar.gz emacs-9045be38cdbf47378af50b0cae7efdca04945ba9.zip | |
(quit-window): Simplify code. Say in doc-string
that it operates on the selected window's buffer. (Bug#1259)
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/window.el | 66 |
2 files changed, 29 insertions, 42 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3ef866e7911..ff2e37deb07 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-10-30 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.el (quit-window): Simplify code. Say in doc-string | ||
| 4 | that it operates on the selected window's buffer. (Bug#1259) | ||
| 5 | |||
| 1 | 2008-10-30 Nick Roberts <nickrob@snap.net.nz> | 6 | 2008-10-30 Nick Roberts <nickrob@snap.net.nz> |
| 2 | 7 | ||
| 3 | * vc-svn.el (vc-svn-diff): If files is nil don't set oldvers to | 8 | * vc-svn.el (vc-svn-diff): If files is nil don't set oldvers to |
diff --git a/lisp/window.el b/lisp/window.el index c9e5d793651..403e4a1d8dc 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -1395,51 +1395,33 @@ or if the window is the only window of its frame." | |||
| 1395 | (error nil))))) | 1395 | (error nil))))) |
| 1396 | 1396 | ||
| 1397 | (defun quit-window (&optional kill window) | 1397 | (defun quit-window (&optional kill window) |
| 1398 | "Quit the current buffer. Bury it, and maybe delete the selected frame. | 1398 | "Bury or kill (with KILL non-nil) the buffer displayed in WINDOW. |
| 1399 | \(The frame is deleted if it contains a dedicated window for the buffer.) | 1399 | KILL defaults to nil, WINDOW to the selected window. If WINDOW |
| 1400 | With a prefix argument, kill the buffer instead. | 1400 | is dedicated or a minibuffer window, delete it and, if it's the |
| 1401 | 1401 | only window on its frame, delete its frame as well provided there | |
| 1402 | Noninteractively, if KILL is non-nil, then kill the current buffer, | 1402 | are other frames left. Otherwise, display some other buffer in |
| 1403 | otherwise bury it. | 1403 | the window." |
| 1404 | 1404 | (interactive) | |
| 1405 | If WINDOW is non-nil, it specifies a window; we delete that window, | 1405 | (let* ((window (or window (selected-window))) |
| 1406 | and the buffer that is killed or buried is the one in that window." | 1406 | (buffer (window-buffer window))) |
| 1407 | (interactive "P") | 1407 | (if (or (window-minibuffer-p window) (window-dedicated-p window)) |
| 1408 | (let ((buffer (window-buffer window)) | 1408 | (if (eq window (frame-root-window (window-frame window))) |
| 1409 | (frame (window-frame (or window (selected-window)))) | 1409 | ;; If this is the only window on its frame, try to delete the |
| 1410 | (window-solitary | 1410 | ;; frame (`delete-windows-on' knows how to do that). |
| 1411 | (save-selected-window | 1411 | (delete-windows-on buffer (selected-frame)) |
| 1412 | (if window | 1412 | ;; Other windows are left, delete this window. But don't |
| 1413 | (select-window window)) | 1413 | ;; throw an error if that fails for some reason. |
| 1414 | (one-window-p t))) | 1414 | (condition-case nil |
| 1415 | window-handled) | 1415 | (delete-window window) |
| 1416 | 1416 | (error nil))) | |
| 1417 | (save-selected-window | 1417 | ;; The window is neither dedicated nor a minibuffer window, |
| 1418 | (if window | 1418 | ;; display another buffer in it. |
| 1419 | (select-window window)) | 1419 | (with-selected-window window |
| 1420 | (or (window-minibuffer-p) | 1420 | (switch-to-buffer (other-buffer)))) |
| 1421 | (window-dedicated-p (selected-window)) | ||
| 1422 | (switch-to-buffer (other-buffer)))) | ||
| 1423 | |||
| 1424 | ;; Get rid of the frame, if it has just one dedicated window | ||
| 1425 | ;; and other visible frames exist. | ||
| 1426 | (and (or (window-minibuffer-p) (window-dedicated-p window)) | ||
| 1427 | (delq frame (visible-frame-list)) | ||
| 1428 | window-solitary | ||
| 1429 | (if (and (eq default-minibuffer-frame frame) | ||
| 1430 | (= 1 (length (minibuffer-frame-list)))) | ||
| 1431 | (setq window nil) | ||
| 1432 | (delete-frame frame) | ||
| 1433 | (setq window-handled t))) | ||
| 1434 | |||
| 1435 | ;; Deal with the buffer. | 1421 | ;; Deal with the buffer. |
| 1436 | (if kill | 1422 | (if kill |
| 1437 | (kill-buffer buffer) | 1423 | (kill-buffer buffer) |
| 1438 | (bury-buffer buffer)) | 1424 | (bury-buffer buffer)))) |
| 1439 | |||
| 1440 | ;; Maybe get rid of the window. | ||
| 1441 | (and window (not window-handled) (not window-solitary) | ||
| 1442 | (delete-window window)))) | ||
| 1443 | 1425 | ||
| 1444 | (defvar recenter-last-op nil | 1426 | (defvar recenter-last-op nil |
| 1445 | "Indicates the last recenter operation performed. | 1427 | "Indicates the last recenter operation performed. |