aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-03-09 00:37:11 +0000
committerRichard M. Stallman1998-03-09 00:37:11 +0000
commit3d2f23d923f2dbb709359d263deaa1800528809c (patch)
tree7db7b508d152fc445bd3333d9315deb973d353cb
parentab228c24d550d34f768077d6c1d047b12c8ff62d (diff)
downloademacs-3d2f23d923f2dbb709359d263deaa1800528809c.tar.gz
emacs-3d2f23d923f2dbb709359d263deaa1800528809c.zip
(quit-window): New command.
(shrink-window-if-larger-than-buffer): Bind text-height in the let*. (view-return-to-alist): Add defvar.
-rw-r--r--lisp/window.el51
1 files changed, 50 insertions, 1 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 2ac97ffd62c..6b8709b00f3 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -198,6 +198,9 @@ new mode line."
198 (select-window new-w))))) 198 (select-window new-w)))))
199 (split-window-save-restore-data new-w old-w))) 199 (split-window-save-restore-data new-w old-w)))
200 200
201;; This is to avoid compiler warnings.
202(defvar view-return-to-alist)
203
201(defun split-window-save-restore-data (new-w old-w) 204(defun split-window-save-restore-data (new-w old-w)
202 (save-excursion 205 (save-excursion
203 (set-buffer (window-buffer)) 206 (set-buffer (window-buffer))
@@ -246,7 +249,8 @@ or if the window is the only window of its frame."
246 (eq ?\n (char-after (1- (point-max)))))) 249 (eq ?\n (char-after (1- (point-max))))))
247 (params (frame-parameters (window-frame window))) 250 (params (frame-parameters (window-frame window)))
248 (mini (cdr (assq 'minibuffer params))) 251 (mini (cdr (assq 'minibuffer params)))
249 (edges (window-edges (selected-window)))) 252 (edges (window-edges (selected-window)))
253 text-height)
250 (if (and (< 1 (save-selected-window 254 (if (and (< 1 (save-selected-window
251 (select-window window) 255 (select-window window)
252 (count-windows))) 256 (count-windows)))
@@ -287,6 +291,51 @@ or if the window is the only window of its frame."
287 (kill-buffer buffer)) 291 (kill-buffer buffer))
288 (error "Aborted"))) 292 (error "Aborted")))
289 293
294(defun quit-window (&optional kill window)
295 "Quit the current buffer. Bury it, and maybe delete the selected frame.
296\(The frame is deleted if it is contains a dedicated window for the buffer.)
297With a prefix argument, kill the buffer instead.
298
299Noninteractively, if KILL is non-nil, then kill the current buffer,
300otherwise bury it.
301
302If WINDOW is non-nil, it specifies a window; we delete that window,
303and the buffer that is killed or buried is the one in that window."
304 (interactive "P")
305 (let ((buffer (window-buffer window))
306 (frame (if window (window-frame window) (selected-window)))
307 (window-solitary
308 (save-selected-window
309 (if window
310 (select-window window))
311 (one-window-p t)))
312 window-handled)
313
314 (save-selected-window
315 (if window
316 (select-window window))
317 (switch-to-buffer (other-buffer)))
318
319 ;; Get rid of the frame, if it has just one dedicated window
320 ;; and other visible frames exist.
321 (and (window-dedicated-p window)
322 (delq frame (visible-frame-list))
323 window-solitary
324 (if (and (eq default-minibuffer-frame frame)
325 (= 1 (length (minibuffer-frame-list))))
326 (setq window nil)
327 (delete-frame frame)
328 (setq window-handled t)))
329
330 ;; Deal with the buffer.
331 (if kill
332 (kill-buffer buffer)
333 (bury-buffer buffer))
334
335 ;; Maybe get rid of the window.
336 (and window (not window-handled) (not window-solitary)
337 (delete-window window))))
338
290(define-key ctl-x-map "2" 'split-window-vertically) 339(define-key ctl-x-map "2" 'split-window-vertically)
291(define-key ctl-x-map "3" 'split-window-horizontally) 340(define-key ctl-x-map "3" 'split-window-horizontally)
292(define-key ctl-x-map "}" 'enlarge-window-horizontally) 341(define-key ctl-x-map "}" 'enlarge-window-horizontally)