From 67222e1dfff23c792ecdd4995dd144c1b41027c9 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Thu, 16 Jun 2011 16:01:46 +0200 Subject: [PATCH] Have enlarge-/shrink-window not report errors in most cases (bug#8862). * window.el (enlarge-window, shrink-window): Don't report an error when the window can't be resized as requested (Bug#8862). --- lisp/ChangeLog | 2 ++ lisp/window.el | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 77ee2fe27a6..b5d76e3f533 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -11,6 +11,8 @@ display-buffer-pop-up-frame. (display-buffer-pop-up-frame): Never pop up a frame in noninteractive mode (Bug#8857). + (enlarge-window, shrink-window): Don't report an error when the + window can't be resized as requested (Bug#8862). 2011-06-15 Stefan Monnier diff --git a/lisp/window.el b/lisp/window.el index 5f9e761b3d7..aa874b8e503 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2044,7 +2044,18 @@ make selected window wider by DELTA columns. If DELTA is negative, shrink selected window by -DELTA lines or columns. Return nil." (interactive "p") - (resize-window (selected-window) delta horizontal)) + (cond + ((zerop delta)) + ((window-size-fixed-p nil horizontal) + (error "Selected window has fixed size")) + ((window-resizable-p nil delta horizontal) + (resize-window nil delta horizontal)) + (t + (resize-window + nil (if (> delta 0) + (window-max-delta nil horizontal) + (- (window-min-delta nil horizontal))) + horizontal)))) (defun shrink-window (delta &optional horizontal) "Make selected window DELTA lines smaller. @@ -2054,7 +2065,18 @@ make selected window narrower by DELTA columns. If DELTA is negative, enlarge selected window by -DELTA lines or columns. Return nil." (interactive "p") - (resize-window (selected-window) (- delta) horizontal)) + (cond + ((zerop delta)) + ((window-size-fixed-p nil horizontal) + (error "Selected window has fixed size")) + ((window-resizable-p nil (- delta) horizontal) + (resize-window nil (- delta) horizontal)) + (t + (resize-window + nil (if (> delta 0) + (- (window-min-delta nil horizontal)) + (window-max-delta nil horizontal)) + horizontal)))) (defun maximize-window (&optional window) "Maximize WINDOW. @@ -4932,7 +4954,7 @@ SPECIFIERS is the SPECIFIERS argument of `display-buffer'." (setq entry (assq specifiers display-buffer-macro-specifiers))) ;; A macro specifier. (cdr entry)) - ((memq pop-up-frames '(nil unset)) + ((with-no-warnings (memq pop-up-frames '(nil unset))) ;; Pop up a new window. (cdr (assq 'other-window display-buffer-macro-specifiers))) (t -- 2.39.2