diff options
| author | Martin Rudalics | 2016-03-04 08:37:53 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2016-03-04 08:37:53 +0100 |
| commit | 620951fe22a6ecc2edc1f78d961f52566a7fe2b6 (patch) | |
| tree | 0c53a8f7b4857e359116ab74e420fe6114e972ae | |
| parent | 2e78353fabe11c768627c50e48375de5693ce7ee (diff) | |
| download | emacs-620951fe22a6ecc2edc1f78d961f52566a7fe2b6.tar.gz emacs-620951fe22a6ecc2edc1f78d961f52566a7fe2b6.zip | |
Fix previous fix of enlarge-/shrink-window
* lisp/window.el (enlarge-window, shrink-window): Consistently
signal user-error instead of error. Resize minibuffer window by
delta lines instead of pixels. When a window cannot be resized,
signal an error only when this function was invoked by a command
in the enlarge-/shrink-window group (this restores the behavior
before the fix of bug#22723 for the non-interactive case).
| -rw-r--r-- | lisp/window.el | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/lisp/window.el b/lisp/window.el index c45e60e6204..7e46aa89b89 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -2473,8 +2473,6 @@ windows." | |||
| 2473 | (when (window-right window) | 2473 | (when (window-right window) |
| 2474 | (window--resize-reset-1 (window-right window) horizontal))) | 2474 | (window--resize-reset-1 (window-right window) horizontal))) |
| 2475 | 2475 | ||
| 2476 | ;; The following routine is used to manually resize the minibuffer | ||
| 2477 | ;; window and is currently used, for example, by ispell.el. | ||
| 2478 | (defun window--resize-mini-window (window delta) | 2476 | (defun window--resize-mini-window (window delta) |
| 2479 | "Resize minibuffer window WINDOW by DELTA pixels. | 2477 | "Resize minibuffer window WINDOW by DELTA pixels. |
| 2480 | If WINDOW cannot be resized by DELTA pixels make it as large (or | 2478 | If WINDOW cannot be resized by DELTA pixels make it as large (or |
| @@ -3338,34 +3336,42 @@ negative, shrink selected window by -DELTA lines or columns." | |||
| 3338 | (cond | 3336 | (cond |
| 3339 | ((zerop delta)) | 3337 | ((zerop delta)) |
| 3340 | ((window-size-fixed-p nil horizontal) | 3338 | ((window-size-fixed-p nil horizontal) |
| 3341 | (error "Selected window has fixed size")) | 3339 | (user-error "Selected window has fixed size")) |
| 3342 | ((window-minibuffer-p) | 3340 | ((window-minibuffer-p) |
| 3343 | (if horizontal | 3341 | (if horizontal |
| 3344 | (error "Cannot resize minibuffer window horizontally") | 3342 | (user-error "Cannot resize minibuffer window horizontally") |
| 3345 | (window--resize-mini-window (selected-window) delta))) | 3343 | (window--resize-mini-window |
| 3344 | (selected-window) (* delta (frame-char-height))))) | ||
| 3346 | ((and (not horizontal) | 3345 | ((and (not horizontal) |
| 3347 | (window-full-height-p) | 3346 | (window-full-height-p) |
| 3348 | (eq (window-frame minibuffer-window) (selected-frame)) | 3347 | (eq (window-frame minibuffer-window) (selected-frame)) |
| 3349 | (not resize-mini-windows)) | 3348 | (not resize-mini-windows)) |
| 3350 | ;; If the selected window is full height and `resize-mini-windows' | 3349 | ;; If the selected window is full height and `resize-mini-windows' |
| 3351 | ;; is nil, resize the minibuffer window. | 3350 | ;; is nil, resize the minibuffer window. |
| 3352 | (window--resize-mini-window minibuffer-window (- delta))) | 3351 | (window--resize-mini-window |
| 3352 | minibuffer-window (* (- delta) (frame-char-height)))) | ||
| 3353 | ((window--resizable-p nil delta horizontal) | 3353 | ((window--resizable-p nil delta horizontal) |
| 3354 | (window-resize nil delta horizontal)) | 3354 | (window-resize nil delta horizontal)) |
| 3355 | ((window--resizable-p nil delta horizontal 'preserved) | 3355 | ((window--resizable-p nil delta horizontal 'preserved) |
| 3356 | (window-resize nil delta horizontal 'preserved)) | 3356 | (window-resize nil delta horizontal 'preserved)) |
| 3357 | ((eq this-command 'enlarge-window) | 3357 | ((eq this-command |
| 3358 | (if horizontal 'enlarge-window-horizontally 'enlarge-window)) | ||
| 3359 | ;; For backward compatibility don't signal an error unless this | ||
| 3360 | ;; command is `enlarge-window(-horizontally)'. | ||
| 3358 | (user-error "Cannot enlarge selected window")) | 3361 | (user-error "Cannot enlarge selected window")) |
| 3359 | (t | 3362 | (t |
| 3360 | (error "Cannot enlarge selected window"))))) | 3363 | (window-resize |
| 3364 | nil (if (> delta 0) | ||
| 3365 | (window-max-delta nil horizontal) | ||
| 3366 | (- (window-min-delta nil horizontal))) | ||
| 3367 | horizontal))))) | ||
| 3361 | 3368 | ||
| 3362 | (defun shrink-window (delta &optional horizontal) | 3369 | (defun shrink-window (delta &optional horizontal) |
| 3363 | "Make the selected window DELTA lines smaller. | 3370 | "Make the selected window DELTA lines smaller. |
| 3364 | Interactively, if no argument is given, make the selected window | 3371 | Interactively, if no argument is given, make the selected window |
| 3365 | one line smaller. If optional argument HORIZONTAL is non-nil, | 3372 | one line smaller. If optional argument HORIZONTAL is non-nil, |
| 3366 | make selected window narrower by DELTA columns. If DELTA is | 3373 | make selected window narrower by DELTA columns. If DELTA is |
| 3367 | negative, enlarge selected window by -DELTA lines or columns. | 3374 | negative, enlarge selected window by -DELTA lines or columns." |
| 3368 | Also see the `window-min-height' variable." | ||
| 3369 | (interactive "p") | 3375 | (interactive "p") |
| 3370 | (let ((minibuffer-window (minibuffer-window))) | 3376 | (let ((minibuffer-window (minibuffer-window))) |
| 3371 | (when (window-preserved-size nil horizontal) | 3377 | (when (window-preserved-size nil horizontal) |
| @@ -3373,26 +3379,35 @@ Also see the `window-min-height' variable." | |||
| 3373 | (cond | 3379 | (cond |
| 3374 | ((zerop delta)) | 3380 | ((zerop delta)) |
| 3375 | ((window-size-fixed-p nil horizontal) | 3381 | ((window-size-fixed-p nil horizontal) |
| 3376 | (error "Selected window has fixed size")) | 3382 | (user-error "Selected window has fixed size")) |
| 3377 | ((window-minibuffer-p) | 3383 | ((window-minibuffer-p) |
| 3378 | (if horizontal | 3384 | (if horizontal |
| 3379 | (error "Cannot resize minibuffer window horizontally") | 3385 | (user-error "Cannot resize minibuffer window horizontally") |
| 3380 | (window--resize-mini-window (selected-window) (- delta)))) | 3386 | (window--resize-mini-window |
| 3387 | (selected-window) (* (- delta) (frame-char-height))))) | ||
| 3381 | ((and (not horizontal) | 3388 | ((and (not horizontal) |
| 3382 | (window-full-height-p) | 3389 | (window-full-height-p) |
| 3383 | (eq (window-frame minibuffer-window) (selected-frame)) | 3390 | (eq (window-frame minibuffer-window) (selected-frame)) |
| 3384 | (not resize-mini-windows)) | 3391 | (not resize-mini-windows)) |
| 3385 | ;; If the selected window is full height and `resize-mini-windows' | 3392 | ;; If the selected window is full height and `resize-mini-windows' |
| 3386 | ;; is nil, resize the minibuffer window. | 3393 | ;; is nil, resize the minibuffer window. |
| 3387 | (window--resize-mini-window minibuffer-window delta)) | 3394 | (window--resize-mini-window |
| 3395 | minibuffer-window (* delta (frame-char-height)))) | ||
| 3388 | ((window--resizable-p nil (- delta) horizontal) | 3396 | ((window--resizable-p nil (- delta) horizontal) |
| 3389 | (window-resize nil (- delta) horizontal)) | 3397 | (window-resize nil (- delta) horizontal)) |
| 3390 | ((window--resizable-p nil (- delta) horizontal 'preserved) | 3398 | ((window--resizable-p nil (- delta) horizontal 'preserved) |
| 3391 | (window-resize nil (- delta) horizontal 'preserved)) | 3399 | (window-resize nil (- delta) horizontal 'preserved)) |
| 3392 | ((eq this-command 'shrink-window) | 3400 | ((eq this-command |
| 3401 | (if horizontal 'shrink-window-horizontally 'shrink-window)) | ||
| 3402 | ;; For backward compatibility don't signal an error unless this | ||
| 3403 | ;; command is `shrink-window(-horizontally)'. | ||
| 3393 | (user-error "Cannot shrink selected window")) | 3404 | (user-error "Cannot shrink selected window")) |
| 3394 | (t | 3405 | (t |
| 3395 | (error "Cannot shrink selected window"))))) | 3406 | (window-resize |
| 3407 | nil (if (> delta 0) | ||
| 3408 | (- (window-min-delta nil horizontal)) | ||
| 3409 | (window-max-delta nil horizontal)) | ||
| 3410 | horizontal))))) | ||
| 3396 | 3411 | ||
| 3397 | (defun maximize-window (&optional window) | 3412 | (defun maximize-window (&optional window) |
| 3398 | "Maximize WINDOW. | 3413 | "Maximize WINDOW. |