diff options
| author | Martin Rudalics | 2012-09-30 11:10:59 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2012-09-30 11:10:59 +0200 |
| commit | 5938d5196d09aff887aa74603c102b1f303a613a (patch) | |
| tree | 57c528aafa761114bf2528593a85642e6e3e5e21 | |
| parent | a97dc380601446c00adfbd1d8e86e73e7d81a359 (diff) | |
| download | emacs-5938d5196d09aff887aa74603c102b1f303a613a.tar.gz emacs-5938d5196d09aff887aa74603c102b1f303a613a.zip | |
Handle window-height and window-width alist entries in `display-buffer'.
In buffer display functions handle window-height/window-width
alist entries. Suggested by Juri Linkov as fix for Bug#1806.
* window.el (window--display-buffer): New argument ALIST. Obey
window-height and window-width alist entries.
(window--try-to-split-window): New argument ALIST. Bind
window-combination-limit to t when the window's size shall be
changed and window-combination-limit equals `window-size'.
(display-buffer-in-atom-window)
(display-buffer-in-major-side-window)
(display-buffer-in-side-window, display-buffer-same-window)
(display-buffer-reuse-window, display-buffer-pop-up-frame)
(display-buffer-pop-up-window, display-buffer-below-selected)
(display-buffer-at-bottom, display-buffer-in-previous-window)
(display-buffer-use-some-window): Adjust all callers of
window--display-buffer and window--try-to-split-window.
(fit-frame-to-buffer): New option.
(fit-window-to-buffer): Can resize frames if fit-frame-to-buffer
is non-nil.
(display-buffer-in-major-side-window): Evaluate window-height /
window-width alist entries.
* help.el (temp-buffer-resize-frames)
(temp-buffer-resize-regexps): Remove options.
(temp-buffer-resize-mode): Adjust doc-string.
(resize-temp-buffer-window): Don't consult
temp-buffer-resize-regexps. Use fit-frame-to-buffer instead of
temp-buffer-resize-frames.
* dired.el (dired-mark-pop-up): Call
display-buffer-below-selected with a fit-window-to-buffer alist
entry.
* window.c (Vwindow_combination_limit): New default value.
(Qwindow_size): New symbol replacing Qtemp_buffer_resize.
| -rw-r--r-- | etc/NEWS | 10 | ||||
| -rw-r--r-- | lisp/ChangeLog | 34 | ||||
| -rw-r--r-- | lisp/dired.el | 3 | ||||
| -rw-r--r-- | lisp/help.el | 70 | ||||
| -rw-r--r-- | lisp/window.el | 324 | ||||
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/window.c | 20 |
7 files changed, 280 insertions, 187 deletions
| @@ -738,14 +738,11 @@ now accept a third argument to avoid choosing the selected window. | |||
| 738 | 738 | ||
| 739 | *** New macro `with-temp-buffer-window'. | 739 | *** New macro `with-temp-buffer-window'. |
| 740 | 740 | ||
| 741 | *** New options `temp-buffer-resize-frames' and | ||
| 742 | `temp-buffer-resize-regexps'. | ||
| 743 | |||
| 744 | *** `temp-buffer-resize-mode' no longer resizes windows that have been | 741 | *** `temp-buffer-resize-mode' no longer resizes windows that have been |
| 745 | reused. | 742 | reused. |
| 746 | 743 | ||
| 747 | *** New function `fit-frame-to-buffer' and new option | 744 | *** New function `fit-frame-to-buffer' and new options |
| 748 | `fit-frame-to-buffer-bottom-margin'. | 745 | `fit-frame-to-buffer' and `fit-frame-to-buffer-bottom-margin'. |
| 749 | 746 | ||
| 750 | *** New display action functions `display-buffer-below-selected', | 747 | *** New display action functions `display-buffer-below-selected', |
| 751 | `display-buffer-at-bottom' and `display-buffer-in-previous-window'. | 748 | `display-buffer-at-bottom' and `display-buffer-in-previous-window'. |
| @@ -760,6 +757,9 @@ non-nil, specifies frame parameters to give any newly-created frame. | |||
| 760 | *** New display action alist entry `previous-window', if non-nil, | 757 | *** New display action alist entry `previous-window', if non-nil, |
| 761 | specifies window to reuse in `display-buffer-in-previous-window'. | 758 | specifies window to reuse in `display-buffer-in-previous-window'. |
| 762 | 759 | ||
| 760 | *** New display action alist entries `window-height' and `window-width' | ||
| 761 | to specify size of new window created by `display-buffer'. | ||
| 762 | |||
| 763 | *** The following variables are obsolete, as they can be replaced by | 763 | *** The following variables are obsolete, as they can be replaced by |
| 764 | appropriate entries in the `display-buffer-alist' function introduced | 764 | appropriate entries in the `display-buffer-alist' function introduced |
| 765 | in Emacs 24.1: | 765 | in Emacs 24.1: |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 65ff71c74f8..3e1b93ae3ba 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,37 @@ | |||
| 1 | 2012-09-30 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | In buffer display functions handle window-height/window-width | ||
| 4 | alist entries. Suggested by Juri Linkov as fix for Bug#1806. | ||
| 5 | * window.el (window--display-buffer): New argument ALIST. Obey | ||
| 6 | window-height and window-width alist entries. | ||
| 7 | (window--try-to-split-window): New argument ALIST. Bind | ||
| 8 | window-combination-limit to t when the window's size shall be | ||
| 9 | changed and window-combination-limit equals `window-size'. | ||
| 10 | (display-buffer-in-atom-window) | ||
| 11 | (display-buffer-in-major-side-window) | ||
| 12 | (display-buffer-in-side-window, display-buffer-same-window) | ||
| 13 | (display-buffer-reuse-window, display-buffer-pop-up-frame) | ||
| 14 | (display-buffer-pop-up-window, display-buffer-below-selected) | ||
| 15 | (display-buffer-at-bottom, display-buffer-in-previous-window) | ||
| 16 | (display-buffer-use-some-window): Adjust all callers of | ||
| 17 | window--display-buffer and window--try-to-split-window. | ||
| 18 | (fit-frame-to-buffer): New option. | ||
| 19 | (fit-window-to-buffer): Can resize frames if fit-frame-to-buffer | ||
| 20 | is non-nil. | ||
| 21 | (display-buffer-in-major-side-window): Evaluate window-height / | ||
| 22 | window-width alist entries. | ||
| 23 | |||
| 24 | * help.el (temp-buffer-resize-frames) | ||
| 25 | (temp-buffer-resize-regexps): Remove options. | ||
| 26 | (temp-buffer-resize-mode): Adjust doc-string. | ||
| 27 | (resize-temp-buffer-window): Don't consult | ||
| 28 | temp-buffer-resize-regexps. Use fit-frame-to-buffer instead of | ||
| 29 | temp-buffer-resize-frames. | ||
| 30 | |||
| 31 | * dired.el (dired-mark-pop-up): Call | ||
| 32 | display-buffer-below-selected with a fit-window-to-buffer alist | ||
| 33 | entry. | ||
| 34 | |||
| 1 | 2012-09-30 Chong Yidong <cyd@gnu.org> | 35 | 2012-09-30 Chong Yidong <cyd@gnu.org> |
| 2 | 36 | ||
| 3 | * simple.el (delete-trailing-whitespace): Avoid an unnecessary | 37 | * simple.el (delete-trailing-whitespace): Avoid an unnecessary |
diff --git a/lisp/dired.el b/lisp/dired.el index e0f90b321aa..8cb3902161a 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -2997,7 +2997,8 @@ argument or confirmation)." | |||
| 2997 | (let ((split-height-threshold 0)) | 2997 | (let ((split-height-threshold 0)) |
| 2998 | (with-temp-buffer-window | 2998 | (with-temp-buffer-window |
| 2999 | buffer | 2999 | buffer |
| 3000 | (cons 'display-buffer-below-selected nil) | 3000 | (cons 'display-buffer-below-selected |
| 3001 | '((window-height . fit-window-to-buffer))) | ||
| 3001 | #'(lambda (window _value) | 3002 | #'(lambda (window _value) |
| 3002 | (with-selected-window window | 3003 | (with-selected-window window |
| 3003 | (unwind-protect | 3004 | (unwind-protect |
diff --git a/lisp/help.el b/lisp/help.el index 707c8e3c84f..0df9c607f69 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -981,26 +981,6 @@ function is called, the window to be resized is selected." | |||
| 981 | :group 'help | 981 | :group 'help |
| 982 | :version "24.2") | 982 | :version "24.2") |
| 983 | 983 | ||
| 984 | (defcustom temp-buffer-resize-frames nil | ||
| 985 | "Non-nil means `temp-buffer-resize-mode' can resize frames. | ||
| 986 | A frame can be resized if and only if its root window is a live | ||
| 987 | window. The height of the root window is subject to the values of | ||
| 988 | `temp-buffer-max-height' and `window-min-height'." | ||
| 989 | :type 'boolean | ||
| 990 | :version "24.2" | ||
| 991 | :group 'help) | ||
| 992 | |||
| 993 | (defcustom temp-buffer-resize-regexps nil | ||
| 994 | "List of regexps that inhibit Temp Buffer Resize mode. | ||
| 995 | Any window of a buffer whose name matches one of these regular | ||
| 996 | expressions is left alone by Temp Buffer Resize mode." | ||
| 997 | :type '(repeat | ||
| 998 | :tag "Buffer" | ||
| 999 | :value "" | ||
| 1000 | (regexp :format "%v")) | ||
| 1001 | :version "24.3" | ||
| 1002 | :group 'help) | ||
| 1003 | |||
| 1004 | (define-minor-mode temp-buffer-resize-mode | 984 | (define-minor-mode temp-buffer-resize-mode |
| 1005 | "Toggle auto-resizing temporary buffer windows (Temp Buffer Resize Mode). | 985 | "Toggle auto-resizing temporary buffer windows (Temp Buffer Resize Mode). |
| 1006 | With a prefix argument ARG, enable Temp Buffer Resize mode if ARG | 986 | With a prefix argument ARG, enable Temp Buffer Resize mode if ARG |
| @@ -1014,9 +994,8 @@ fit the buffer's contents, but never more than | |||
| 1014 | 994 | ||
| 1015 | A window is resized only if it has been specially created for the | 995 | A window is resized only if it has been specially created for the |
| 1016 | buffer. Windows that have shown another buffer before are not | 996 | buffer. Windows that have shown another buffer before are not |
| 1017 | resized. A window showing a buffer whose name matches any of the | 997 | resized. A frame is resized only if `fit-frame-to-buffer' is |
| 1018 | expressions in `temp-buffer-resize-regexps' is not resized. A | 998 | non-nil. |
| 1019 | frame is resized only if `temp-buffer-resize-frames' is non-nil. | ||
| 1020 | 999 | ||
| 1021 | This mode is used by `help', `apropos' and `completion' buffers, | 1000 | This mode is used by `help', `apropos' and `completion' buffers, |
| 1022 | and some others." | 1001 | and some others." |
| @@ -1034,33 +1013,28 @@ WINDOW can be any live window and defaults to the selected one. | |||
| 1034 | Do not make WINDOW higher than `temp-buffer-max-height' nor | 1013 | Do not make WINDOW higher than `temp-buffer-max-height' nor |
| 1035 | smaller than `window-min-height'. Do nothing if WINDOW is not | 1014 | smaller than `window-min-height'. Do nothing if WINDOW is not |
| 1036 | vertically combined or some of its contents are scrolled out of | 1015 | vertically combined or some of its contents are scrolled out of |
| 1037 | view. Do nothing if the name of WINDOW's buffer matches an | 1016 | view." |
| 1038 | expression in `temp-buffer-resize-regexps'." | ||
| 1039 | (setq window (window-normalize-window window t)) | 1017 | (setq window (window-normalize-window window t)) |
| 1040 | (let ((buffer-name (buffer-name (window-buffer window)))) | 1018 | (let ((buffer-name (buffer-name (window-buffer window)))) |
| 1041 | (unless (catch 'found | 1019 | (let ((height (if (functionp temp-buffer-max-height) |
| 1042 | (dolist (regexp temp-buffer-resize-regexps) | 1020 | (with-selected-window window |
| 1043 | (when (string-match regexp buffer-name) | 1021 | (funcall temp-buffer-max-height (window-buffer))) |
| 1044 | (throw 'found t)))) | 1022 | temp-buffer-max-height)) |
| 1045 | (let ((height (if (functionp temp-buffer-max-height) | 1023 | (quit-cadr (cadr (window-parameter window 'quit-restore)))) |
| 1046 | (with-selected-window window | 1024 | (cond |
| 1047 | (funcall temp-buffer-max-height (window-buffer))) | 1025 | ;; Don't resize WINDOW if it showed another buffer before. |
| 1048 | temp-buffer-max-height)) | 1026 | ((and (eq quit-cadr 'window) |
| 1049 | (quit-cadr (cadr (window-parameter window 'quit-restore)))) | 1027 | (pos-visible-in-window-p (point-min) window) |
| 1050 | (cond | 1028 | (window-combined-p window)) |
| 1051 | ;; Don't resize WINDOW if it showed another buffer before. | 1029 | (fit-window-to-buffer window height)) |
| 1052 | ((and (eq quit-cadr 'window) | 1030 | ((and fit-frame-to-buffer |
| 1053 | (pos-visible-in-window-p (point-min) window) | 1031 | (eq quit-cadr 'frame) |
| 1054 | (window-combined-p window)) | 1032 | (eq window (frame-root-window window))) |
| 1055 | (fit-window-to-buffer window height)) | 1033 | (let ((frame (window-frame window))) |
| 1056 | ((and temp-buffer-resize-frames | 1034 | (fit-frame-to-buffer |
| 1057 | (eq quit-cadr 'frame) | 1035 | frame (+ (frame-height frame) |
| 1058 | (eq window (frame-root-window window))) | 1036 | (- (window-total-size window)) |
| 1059 | (let ((frame (window-frame window))) | 1037 | height)))))))) |
| 1060 | (fit-frame-to-buffer | ||
| 1061 | frame (+ (frame-height frame) | ||
| 1062 | (- (window-total-size window)) | ||
| 1063 | height))))))))) | ||
| 1064 | 1038 | ||
| 1065 | ;;; Help windows. | 1039 | ;;; Help windows. |
| 1066 | (defcustom help-window-select 'other | 1040 | (defcustom help-window-select 'other |
diff --git a/lisp/window.el b/lisp/window.el index b978eacc0be..3f399bc39fb 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -508,7 +508,7 @@ failed." | |||
| 508 | (window-make-atom (window-parent window)) | 508 | (window-make-atom (window-parent window)) |
| 509 | ;; Display BUFFER in NEW and return NEW. | 509 | ;; Display BUFFER in NEW and return NEW. |
| 510 | (window--display-buffer | 510 | (window--display-buffer |
| 511 | buffer new 'window display-buffer-mark-dedicated)))) | 511 | buffer new 'window alist display-buffer-mark-dedicated)))) |
| 512 | 512 | ||
| 513 | (defun window--atom-check-1 (window) | 513 | (defun window--atom-check-1 (window) |
| 514 | "Subroutine of `window--atom-check'." | 514 | "Subroutine of `window--atom-check'." |
| @@ -677,12 +677,6 @@ The new window automatically becomes the \"major\" side window on | |||
| 677 | SIDE. Return the new window, nil if its creation window failed." | 677 | SIDE. Return the new window, nil if its creation window failed." |
| 678 | (let* ((root (frame-root-window)) | 678 | (let* ((root (frame-root-window)) |
| 679 | (left-or-right (memq side '(left right))) | 679 | (left-or-right (memq side '(left right))) |
| 680 | (size (or (assq 'size alist) | ||
| 681 | (/ (window-total-size (frame-root-window) left-or-right) | ||
| 682 | ;; By default use a fourth of the size of the | ||
| 683 | ;; frame's root window. This has to be made | ||
| 684 | ;; customizable via ALIST. | ||
| 685 | 4))) | ||
| 686 | (major (window--major-side-window side)) | 680 | (major (window--major-side-window side)) |
| 687 | (selected-window (selected-window)) | 681 | (selected-window (selected-window)) |
| 688 | (on-side (cond | 682 | (on-side (cond |
| @@ -694,7 +688,7 @@ SIDE. Return the new window, nil if its creation window failed." | |||
| 694 | ;; parent window unless needed. | 688 | ;; parent window unless needed. |
| 695 | (window-combination-resize 'side) | 689 | (window-combination-resize 'side) |
| 696 | (window-combination-limit nil) | 690 | (window-combination-limit nil) |
| 697 | (new (split-window major (- size) on-side)) | 691 | (new (split-window major nil on-side)) |
| 698 | fun) | 692 | fun) |
| 699 | (when new | 693 | (when new |
| 700 | ;; Initialize `window-side' parameter of new window to SIDE. | 694 | ;; Initialize `window-side' parameter of new window to SIDE. |
| @@ -705,8 +699,22 @@ SIDE. Return the new window, nil if its creation window failed." | |||
| 705 | ;; the new window is deleted, a side window on the opposite side | 699 | ;; the new window is deleted, a side window on the opposite side |
| 706 | ;; does not get resized. | 700 | ;; does not get resized. |
| 707 | (set-window-parameter new 'delete-window 'delete-side-window) | 701 | (set-window-parameter new 'delete-window 'delete-side-window) |
| 702 | ;; Auto-adjust height/width of new window unless a size has been | ||
| 703 | ;; explicitly requested. | ||
| 704 | (unless (if left-or-right | ||
| 705 | (cdr (assq 'window-width alist)) | ||
| 706 | (cdr (assq 'window-height alist))) | ||
| 707 | (setq alist | ||
| 708 | (cons | ||
| 709 | (cons | ||
| 710 | (if left-or-right 'window-width 'window-height) | ||
| 711 | (/ (window-total-size (frame-root-window) left-or-right) | ||
| 712 | ;; By default use a fourth of the size of the | ||
| 713 | ;; frame's root window. | ||
| 714 | 4)) | ||
| 715 | alist))) | ||
| 708 | ;; Install BUFFER in new window and return NEW. | 716 | ;; Install BUFFER in new window and return NEW. |
| 709 | (window--display-buffer buffer new 'window 'side)))) | 717 | (window--display-buffer buffer new 'window alist 'side)))) |
| 710 | 718 | ||
| 711 | (defun delete-side-window (window) | 719 | (defun delete-side-window (window) |
| 712 | "Delete side window WINDOW." | 720 | "Delete side window WINDOW." |
| @@ -814,7 +822,7 @@ following symbols can be used: | |||
| 814 | ;; ALIST (or, better, avoided in the "other" functions). | 822 | ;; ALIST (or, better, avoided in the "other" functions). |
| 815 | (or (and this-window | 823 | (or (and this-window |
| 816 | ;; Reuse `this-window'. | 824 | ;; Reuse `this-window'. |
| 817 | (window--display-buffer buffer this-window 'reuse 'side)) | 825 | (window--display-buffer buffer this-window 'reuse alist 'side)) |
| 818 | (and (or (not max-slots) (< slots max-slots)) | 826 | (and (or (not max-slots) (< slots max-slots)) |
| 819 | (or (and next-window | 827 | (or (and next-window |
| 820 | ;; Make new window before `next-window'. | 828 | ;; Make new window before `next-window'. |
| @@ -839,13 +847,14 @@ following symbols can be used: | |||
| 839 | window 'delete-window 'delete-side-window) | 847 | window 'delete-window 'delete-side-window) |
| 840 | window))) | 848 | window))) |
| 841 | (set-window-parameter window 'window-slot slot) | 849 | (set-window-parameter window 'window-slot slot) |
| 842 | (window--display-buffer buffer window 'window 'side)) | 850 | (window--display-buffer buffer window 'window alist 'side)) |
| 843 | (and best-window | 851 | (and best-window |
| 844 | ;; Reuse `best-window'. | 852 | ;; Reuse `best-window'. |
| 845 | (progn | 853 | (progn |
| 846 | ;; Give best-window the new slot value. | 854 | ;; Give best-window the new slot value. |
| 847 | (set-window-parameter best-window 'window-slot slot) | 855 | (set-window-parameter best-window 'window-slot slot) |
| 848 | (window--display-buffer buffer best-window 'reuse 'side))))))))) | 856 | (window--display-buffer |
| 857 | buffer best-window 'reuse alist 'side))))))))) | ||
| 849 | 858 | ||
| 850 | (defun window--side-check (&optional frame) | 859 | (defun window--side-check (&optional frame) |
| 851 | "Check the side window configuration of FRAME. | 860 | "Check the side window configuration of FRAME. |
| @@ -5077,7 +5086,7 @@ split." | |||
| 5077 | (with-selected-window window | 5086 | (with-selected-window window |
| 5078 | (split-window-below)))))))) | 5087 | (split-window-below)))))))) |
| 5079 | 5088 | ||
| 5080 | (defun window--try-to-split-window (window) | 5089 | (defun window--try-to-split-window (window &optional alist) |
| 5081 | "Try to split WINDOW. | 5090 | "Try to split WINDOW. |
| 5082 | Return value returned by `split-window-preferred-function' if it | 5091 | Return value returned by `split-window-preferred-function' if it |
| 5083 | represents a live window, nil otherwise." | 5092 | represents a live window, nil otherwise." |
| @@ -5085,9 +5094,14 @@ represents a live window, nil otherwise." | |||
| 5085 | (not (frame-parameter (window-frame window) 'unsplittable)) | 5094 | (not (frame-parameter (window-frame window) 'unsplittable)) |
| 5086 | (let* ((window-combination-limit | 5095 | (let* ((window-combination-limit |
| 5087 | ;; When `window-combination-limit' equals | 5096 | ;; When `window-combination-limit' equals |
| 5088 | ;; `display-buffer' bind it to t so resizing steals | 5097 | ;; `display-buffer' or equals `resize-window' and a |
| 5089 | ;; space preferably from the window that was split. | 5098 | ;; `window-height' or `window-width' alist entry are |
| 5090 | (if (eq window-combination-limit 'display-buffer) | 5099 | ;; present, bind it to t so resizing steals space |
| 5100 | ;; preferably from the window that was split. | ||
| 5101 | (if (or (eq window-combination-limit 'display-buffer) | ||
| 5102 | (and (eq window-combination-limit 'window-size) | ||
| 5103 | (or (cdr (assq 'window-height alist)) | ||
| 5104 | (cdr (assq 'window-width alist))))) | ||
| 5091 | t | 5105 | t |
| 5092 | window-combination-limit)) | 5106 | window-combination-limit)) |
| 5093 | (new-window | 5107 | (new-window |
| @@ -5144,7 +5158,7 @@ is higher than WINDOW." | |||
| 5144 | (/ (- (window-total-height window) (window-total-height)) 2)) | 5158 | (/ (- (window-total-height window) (window-total-height)) 2)) |
| 5145 | (error nil)))) | 5159 | (error nil)))) |
| 5146 | 5160 | ||
| 5147 | (defun window--display-buffer (buffer window type &optional dedicated) | 5161 | (defun window--display-buffer (buffer window type &optional alist dedicated) |
| 5148 | "Display BUFFER in WINDOW and make its frame visible. | 5162 | "Display BUFFER in WINDOW and make its frame visible. |
| 5149 | TYPE must be one of the symbols `reuse', `window' or `frame' and | 5163 | TYPE must be one of the symbols `reuse', `window' or `frame' and |
| 5150 | is passed unaltered to `display-buffer-record-window'. Set | 5164 | is passed unaltered to `display-buffer-record-window'. Set |
| @@ -5159,6 +5173,58 @@ BUFFER and WINDOW are live." | |||
| 5159 | (set-window-dedicated-p window dedicated)) | 5173 | (set-window-dedicated-p window dedicated)) |
| 5160 | (when (memq type '(window frame)) | 5174 | (when (memq type '(window frame)) |
| 5161 | (set-window-prev-buffers window nil))) | 5175 | (set-window-prev-buffers window nil))) |
| 5176 | (let ((parameter (window-parameter window 'quit-restore)) | ||
| 5177 | (height (cdr (assq 'window-height alist))) | ||
| 5178 | (width (cdr (assq 'window-width alist)))) | ||
| 5179 | (when (or (memq type '(window frame)) | ||
| 5180 | (and (eq (car parameter) 'same) | ||
| 5181 | (memq (nth 1 parameter) '(window frame)))) | ||
| 5182 | ;; Adjust height of new window or frame. | ||
| 5183 | (cond | ||
| 5184 | ((not height)) | ||
| 5185 | ((numberp height) | ||
| 5186 | (let* ((new-height | ||
| 5187 | (if (integerp height) | ||
| 5188 | height | ||
| 5189 | (round | ||
| 5190 | (* (window-total-size (frame-root-window window)) | ||
| 5191 | height)))) | ||
| 5192 | (delta (- new-height (window-total-size window)))) | ||
| 5193 | (cond | ||
| 5194 | ((and (window-resizable-p window delta nil 'safe) | ||
| 5195 | (window-combined-p window)) | ||
| 5196 | (window-resize window delta nil 'safe)) | ||
| 5197 | ((or (eq type 'frame) | ||
| 5198 | (and (eq (car parameter) 'same) | ||
| 5199 | (eq (nth 1 parameter) 'frame))) | ||
| 5200 | (set-frame-height | ||
| 5201 | (window-frame window) | ||
| 5202 | (+ (frame-height (window-frame window)) delta)))))) | ||
| 5203 | ((functionp height) | ||
| 5204 | (ignore-errors (funcall height window)))) | ||
| 5205 | ;; Adjust width of a window or frame. | ||
| 5206 | (cond | ||
| 5207 | ((not width)) | ||
| 5208 | ((numberp width) | ||
| 5209 | (let* ((new-width | ||
| 5210 | (if (integerp width) | ||
| 5211 | width | ||
| 5212 | (round | ||
| 5213 | (* (window-total-size (frame-root-window window) t) | ||
| 5214 | width)))) | ||
| 5215 | (delta (- new-width (window-total-size window t)))) | ||
| 5216 | (cond | ||
| 5217 | ((and (window-resizable-p window delta t 'safe) | ||
| 5218 | (window-combined-p window t)) | ||
| 5219 | (window-resize window delta t 'safe)) | ||
| 5220 | ((or (eq type 'frame) | ||
| 5221 | (and (eq (car parameter) 'same) | ||
| 5222 | (eq (nth 1 parameter) 'frame))) | ||
| 5223 | (set-frame-width | ||
| 5224 | (window-frame window) | ||
| 5225 | (+ (frame-width (window-frame window)) delta)))))) | ||
| 5226 | ((functionp width) | ||
| 5227 | (ignore-errors (funcall width window)))))) | ||
| 5162 | window)) | 5228 | window)) |
| 5163 | 5229 | ||
| 5164 | (defun window--maybe-raise-frame (frame) | 5230 | (defun window--maybe-raise-frame (frame) |
| @@ -5400,7 +5466,7 @@ selected window." | |||
| 5400 | (unless (or (cdr (assq 'inhibit-same-window alist)) | 5466 | (unless (or (cdr (assq 'inhibit-same-window alist)) |
| 5401 | (window-minibuffer-p) | 5467 | (window-minibuffer-p) |
| 5402 | (window-dedicated-p)) | 5468 | (window-dedicated-p)) |
| 5403 | (window--display-buffer buffer (selected-window) 'reuse))) | 5469 | (window--display-buffer buffer (selected-window) 'reuse alist))) |
| 5404 | 5470 | ||
| 5405 | (defun display-buffer--maybe-same-window (buffer alist) | 5471 | (defun display-buffer--maybe-same-window (buffer alist) |
| 5406 | "Conditionally display BUFFER in the selected window. | 5472 | "Conditionally display BUFFER in the selected window. |
| @@ -5448,7 +5514,7 @@ that frame." | |||
| 5448 | (get-buffer-window-list buffer 'nomini | 5514 | (get-buffer-window-list buffer 'nomini |
| 5449 | frames)))))) | 5515 | frames)))))) |
| 5450 | (when (window-live-p window) | 5516 | (when (window-live-p window) |
| 5451 | (prog1 (window--display-buffer buffer window 'reuse) | 5517 | (prog1 (window--display-buffer buffer window 'reuse alist) |
| 5452 | (unless (cdr (assq 'inhibit-switch-frame alist)) | 5518 | (unless (cdr (assq 'inhibit-switch-frame alist)) |
| 5453 | (window--maybe-raise-frame (window-frame window))))))) | 5519 | (window--maybe-raise-frame (window-frame window))))))) |
| 5454 | 5520 | ||
| @@ -5485,8 +5551,8 @@ new frame." | |||
| 5485 | (when (and fun | 5551 | (when (and fun |
| 5486 | (setq frame (funcall fun)) | 5552 | (setq frame (funcall fun)) |
| 5487 | (setq window (frame-selected-window frame))) | 5553 | (setq window (frame-selected-window frame))) |
| 5488 | (prog1 (window--display-buffer buffer window | 5554 | (prog1 (window--display-buffer |
| 5489 | 'frame display-buffer-mark-dedicated) | 5555 | buffer window 'frame alist display-buffer-mark-dedicated) |
| 5490 | (unless (cdr (assq 'inhibit-switch-frame alist)) | 5556 | (unless (cdr (assq 'inhibit-switch-frame alist)) |
| 5491 | (window--maybe-raise-frame frame)))))) | 5557 | (window--maybe-raise-frame frame)))))) |
| 5492 | 5558 | ||
| @@ -5511,11 +5577,11 @@ raising the frame." | |||
| 5511 | (not (frame-parameter frame 'unsplittable)))) | 5577 | (not (frame-parameter frame 'unsplittable)))) |
| 5512 | ;; Attempt to split largest or least recently used window. | 5578 | ;; Attempt to split largest or least recently used window. |
| 5513 | (setq window (or (window--try-to-split-window | 5579 | (setq window (or (window--try-to-split-window |
| 5514 | (get-largest-window frame t)) | 5580 | (get-largest-window frame t) alist) |
| 5515 | (window--try-to-split-window | 5581 | (window--try-to-split-window |
| 5516 | (get-lru-window frame t))))) | 5582 | (get-lru-window frame t) alist)))) |
| 5517 | (prog1 (window--display-buffer buffer window | 5583 | (prog1 (window--display-buffer |
| 5518 | 'window display-buffer-mark-dedicated) | 5584 | buffer window 'window alist display-buffer-mark-dedicated) |
| 5519 | (unless (cdr (assq 'inhibit-switch-frame alist)) | 5585 | (unless (cdr (assq 'inhibit-switch-frame alist)) |
| 5520 | (window--maybe-raise-frame (window-frame window))))))) | 5586 | (window--maybe-raise-frame (window-frame window))))))) |
| 5521 | 5587 | ||
| @@ -5534,21 +5600,21 @@ again with `display-buffer-pop-up-window'." | |||
| 5534 | (and pop-up-windows | 5600 | (and pop-up-windows |
| 5535 | (display-buffer-pop-up-window buffer alist)))) | 5601 | (display-buffer-pop-up-window buffer alist)))) |
| 5536 | 5602 | ||
| 5537 | (defun display-buffer-below-selected (buffer _alist) | 5603 | (defun display-buffer-below-selected (buffer alist) |
| 5538 | "Try displaying BUFFER in a window below the selected window. | 5604 | "Try displaying BUFFER in a window below the selected window. |
| 5539 | This either splits the selected window or reuses the window below | 5605 | This either splits the selected window or reuses the window below |
| 5540 | the selected one." | 5606 | the selected one." |
| 5541 | (let (window) | 5607 | (let (window) |
| 5542 | (or (and (not (frame-parameter nil 'unsplittable)) | 5608 | (or (and (not (frame-parameter nil 'unsplittable)) |
| 5543 | (setq window (window--try-to-split-window (selected-window))) | 5609 | (setq window (window--try-to-split-window (selected-window) alist)) |
| 5544 | (window--display-buffer | 5610 | (window--display-buffer |
| 5545 | buffer window 'window display-buffer-mark-dedicated)) | 5611 | buffer window 'window alist display-buffer-mark-dedicated)) |
| 5546 | (and (setq window (window-in-direction 'below)) | 5612 | (and (setq window (window-in-direction 'below)) |
| 5547 | (not (window-dedicated-p window)) | 5613 | (not (window-dedicated-p window)) |
| 5548 | (window--display-buffer | 5614 | (window--display-buffer |
| 5549 | buffer window 'reuse display-buffer-mark-dedicated))))) | 5615 | buffer window 'reuse alist display-buffer-mark-dedicated))))) |
| 5550 | 5616 | ||
| 5551 | (defun display-buffer-at-bottom (buffer _alist) | 5617 | (defun display-buffer-at-bottom (buffer alist) |
| 5552 | "Try displaying BUFFER in a window at the botom of the selected frame. | 5618 | "Try displaying BUFFER in a window at the botom of the selected frame. |
| 5553 | This either splits the window at the bottom of the frame or the | 5619 | This either splits the window at the bottom of the frame or the |
| 5554 | frame's root window, or reuses an existing window at the bottom | 5620 | frame's root window, or reuses an existing window at the bottom |
| @@ -5556,20 +5622,20 @@ of the selected frame." | |||
| 5556 | (let (bottom-window window) | 5622 | (let (bottom-window window) |
| 5557 | (walk-window-tree (lambda (window) (setq bottom-window window))) | 5623 | (walk-window-tree (lambda (window) (setq bottom-window window))) |
| 5558 | (or (and (not (frame-parameter nil 'unsplittable)) | 5624 | (or (and (not (frame-parameter nil 'unsplittable)) |
| 5559 | (setq window (window--try-to-split-window bottom-window)) | 5625 | (setq window (window--try-to-split-window bottom-window alist)) |
| 5560 | (window--display-buffer | 5626 | (window--display-buffer |
| 5561 | buffer window 'window display-buffer-mark-dedicated)) | 5627 | buffer window 'window alist display-buffer-mark-dedicated)) |
| 5562 | (and (not (frame-parameter nil 'unsplittable)) | 5628 | (and (not (frame-parameter nil 'unsplittable)) |
| 5563 | (setq window | 5629 | (setq window |
| 5564 | (condition-case nil | 5630 | (condition-case nil |
| 5565 | (split-window (frame-root-window)) | 5631 | (split-window (frame-root-window)) |
| 5566 | (error nil))) | 5632 | (error nil))) |
| 5567 | (window--display-buffer | 5633 | (window--display-buffer |
| 5568 | buffer window 'window display-buffer-mark-dedicated)) | 5634 | buffer window 'window alist display-buffer-mark-dedicated)) |
| 5569 | (and (setq window bottom-window) | 5635 | (and (setq window bottom-window) |
| 5570 | (not (window-dedicated-p window)) | 5636 | (not (window-dedicated-p window)) |
| 5571 | (window--display-buffer | 5637 | (window--display-buffer |
| 5572 | buffer window 'reuse display-buffer-mark-dedicated))))) | 5638 | buffer window 'reuse alist display-buffer-mark-dedicated))))) |
| 5573 | 5639 | ||
| 5574 | (defun display-buffer-in-previous-window (buffer alist) | 5640 | (defun display-buffer-in-previous-window (buffer alist) |
| 5575 | "Display BUFFER in a window previously showing it. | 5641 | "Display BUFFER in a window previously showing it. |
| @@ -5625,7 +5691,7 @@ above, even if that window never showed BUFFER before." | |||
| 5625 | (setq best-window window))) | 5691 | (setq best-window window))) |
| 5626 | ;; Return best or second best window found. | 5692 | ;; Return best or second best window found. |
| 5627 | (when (setq window (or best-window second-best-window)) | 5693 | (when (setq window (or best-window second-best-window)) |
| 5628 | (window--display-buffer buffer window 'reuse)))) | 5694 | (window--display-buffer buffer window 'reuse alist)))) |
| 5629 | 5695 | ||
| 5630 | (defun display-buffer-use-some-window (buffer alist) | 5696 | (defun display-buffer-use-some-window (buffer alist) |
| 5631 | "Display BUFFER in an existing window. | 5697 | "Display BUFFER in an existing window. |
| @@ -5653,7 +5719,7 @@ that frame." | |||
| 5653 | (get-largest-window 0 not-this-window)))) | 5719 | (get-largest-window 0 not-this-window)))) |
| 5654 | (when (window-live-p window) | 5720 | (when (window-live-p window) |
| 5655 | (prog1 | 5721 | (prog1 |
| 5656 | (window--display-buffer buffer window 'reuse) | 5722 | (window--display-buffer buffer window 'reuse alist) |
| 5657 | (window--even-window-heights window) | 5723 | (window--even-window-heights window) |
| 5658 | (unless (cdr (assq 'inhibit-switch-frame alist)) | 5724 | (unless (cdr (assq 'inhibit-switch-frame alist)) |
| 5659 | (window--maybe-raise-frame (window-frame window))))))) | 5725 | (window--maybe-raise-frame (window-frame window))))))) |
| @@ -5923,6 +5989,97 @@ WINDOW must be a live window and defaults to the selected one." | |||
| 5923 | window)))) | 5989 | window)))) |
| 5924 | 5990 | ||
| 5925 | ;;; Resizing buffers to fit their contents exactly. | 5991 | ;;; Resizing buffers to fit their contents exactly. |
| 5992 | (defcustom fit-frame-to-buffer nil | ||
| 5993 | "Non-nil means `fit-window-to-buffer' can resize frames. | ||
| 5994 | A frame can be resized if and only if its root window is a live | ||
| 5995 | window. The height of the root window is subject to the values | ||
| 5996 | of `fit-frame-to-buffer-max-height' and `window-min-height'." | ||
| 5997 | :type 'boolean | ||
| 5998 | :version "24.2" | ||
| 5999 | :group 'help) | ||
| 6000 | |||
| 6001 | (defcustom fit-frame-to-buffer-bottom-margin 4 | ||
| 6002 | "Bottom margin for `fit-frame-to-buffer'. | ||
| 6003 | This is the number of lines `fit-frame-to-buffer' leaves free at the | ||
| 6004 | bottom of the display in order to not obscure the system task bar." | ||
| 6005 | :type 'integer | ||
| 6006 | :version "24.2" | ||
| 6007 | :group 'windows) | ||
| 6008 | |||
| 6009 | (defun fit-frame-to-buffer (&optional frame max-height min-height) | ||
| 6010 | "Adjust height of FRAME to display its buffer's contents exactly. | ||
| 6011 | FRAME can be any live frame and defaults to the selected one. | ||
| 6012 | |||
| 6013 | Optional argument MAX-HEIGHT specifies the maximum height of | ||
| 6014 | FRAME and defaults to the height of the display below the current | ||
| 6015 | top line of FRAME minus FIT-FRAME-TO-BUFFER-BOTTOM-MARGIN. | ||
| 6016 | Optional argument MIN-HEIGHT specifies the minimum height of | ||
| 6017 | FRAME." | ||
| 6018 | (interactive) | ||
| 6019 | (setq frame (window-normalize-frame frame)) | ||
| 6020 | (let* ((root (frame-root-window frame)) | ||
| 6021 | (frame-min-height | ||
| 6022 | (+ (- (frame-height frame) (window-total-size root)) | ||
| 6023 | window-min-height)) | ||
| 6024 | (frame-top (frame-parameter frame 'top)) | ||
| 6025 | (top (if (consp frame-top) | ||
| 6026 | (funcall (car frame-top) (cadr frame-top)) | ||
| 6027 | frame-top)) | ||
| 6028 | (frame-max-height | ||
| 6029 | (- (/ (- (x-display-pixel-height frame) top) | ||
| 6030 | (frame-char-height frame)) | ||
| 6031 | fit-frame-to-buffer-bottom-margin)) | ||
| 6032 | (compensate 0) | ||
| 6033 | delta) | ||
| 6034 | (when (and (window-live-p root) (not (window-size-fixed-p root))) | ||
| 6035 | (with-selected-window root | ||
| 6036 | (cond | ||
| 6037 | ((not max-height) | ||
| 6038 | (setq max-height frame-max-height)) | ||
| 6039 | ((numberp max-height) | ||
| 6040 | (setq max-height (min max-height frame-max-height))) | ||
| 6041 | (t | ||
| 6042 | (error "%s is an invalid maximum height" max-height))) | ||
| 6043 | (cond | ||
| 6044 | ((not min-height) | ||
| 6045 | (setq min-height frame-min-height)) | ||
| 6046 | ((numberp min-height) | ||
| 6047 | (setq min-height (min min-height frame-min-height))) | ||
| 6048 | (t | ||
| 6049 | (error "%s is an invalid minimum height" min-height))) | ||
| 6050 | ;; When tool-bar-mode is enabled and we have just created a new | ||
| 6051 | ;; frame, reserve lines for toolbar resizing. This is needed | ||
| 6052 | ;; because for reasons unknown to me Emacs (1) reserves one line | ||
| 6053 | ;; for the toolbar when making the initial frame and toolbars | ||
| 6054 | ;; are enabled, and (2) later adds the remaining lines needed. | ||
| 6055 | ;; Our code runs IN BETWEEN (1) and (2). YMMV when you're on a | ||
| 6056 | ;; system that behaves differently. | ||
| 6057 | (let ((quit-restore (window-parameter root 'quit-restore)) | ||
| 6058 | (lines (tool-bar-lines-needed frame))) | ||
| 6059 | (when (and quit-restore (eq (car quit-restore) 'frame) | ||
| 6060 | (not (zerop lines))) | ||
| 6061 | (setq compensate (1- lines)))) | ||
| 6062 | (message "%s" compensate) | ||
| 6063 | (setq delta | ||
| 6064 | ;; Always count a final newline - we don't do any | ||
| 6065 | ;; post-processing, so let's play safe. | ||
| 6066 | (+ (count-screen-lines nil nil t) | ||
| 6067 | (- (window-body-size)) | ||
| 6068 | compensate))) | ||
| 6069 | ;; Move away from final newline. | ||
| 6070 | (when (and (eobp) (bolp) (not (bobp))) | ||
| 6071 | (set-window-point root (line-beginning-position 0))) | ||
| 6072 | (set-window-start root (point-min)) | ||
| 6073 | (set-window-vscroll root 0) | ||
| 6074 | (condition-case nil | ||
| 6075 | (set-frame-height | ||
| 6076 | frame | ||
| 6077 | (min (max (+ (frame-height frame) delta) | ||
| 6078 | min-height) | ||
| 6079 | max-height)) | ||
| 6080 | (error (setq delta nil)))) | ||
| 6081 | delta)) | ||
| 6082 | |||
| 5926 | (defun fit-window-to-buffer (&optional window max-height min-height) | 6083 | (defun fit-window-to-buffer (&optional window max-height min-height) |
| 5927 | "Adjust height of WINDOW to display its buffer's contents exactly. | 6084 | "Adjust height of WINDOW to display its buffer's contents exactly. |
| 5928 | WINDOW must be a live window and defaults to the selected one. | 6085 | WINDOW must be a live window and defaults to the selected one. |
| @@ -5943,9 +6100,12 @@ _all_ lines of its buffer you might not see the first lines when | |||
| 5943 | WINDOW was scrolled." | 6100 | WINDOW was scrolled." |
| 5944 | (interactive) | 6101 | (interactive) |
| 5945 | (setq window (window-normalize-window window t)) | 6102 | (setq window (window-normalize-window window t)) |
| 5946 | ;; Can't resize a full height or fixed-size window. | 6103 | (cond |
| 5947 | (unless (or (window-size-fixed-p window) | 6104 | ((window-size-fixed-p window)) |
| 5948 | (window-full-height-p window)) | 6105 | ((window-full-height-p window) |
| 6106 | (when fit-frame-to-buffer | ||
| 6107 | (fit-frame-to-buffer (window-frame window)))) | ||
| 6108 | (t | ||
| 5949 | (with-selected-window window | 6109 | (with-selected-window window |
| 5950 | (let* ((height (window-total-size)) | 6110 | (let* ((height (window-total-size)) |
| 5951 | (min-height | 6111 | (min-height |
| @@ -5961,7 +6121,7 @@ WINDOW was scrolled." | |||
| 5961 | ;; Can't get larger than height of frame. | 6121 | ;; Can't get larger than height of frame. |
| 5962 | (min max-height | 6122 | (min max-height |
| 5963 | (window-total-size (frame-root-window window))) | 6123 | (window-total-size (frame-root-window window))) |
| 5964 | ;, Don't delete other windows. | 6124 | ;; Don't delete other windows. |
| 5965 | (+ height (window-max-delta nil nil window)))) | 6125 | (+ height (window-max-delta nil nil window)))) |
| 5966 | ;; Make `desired-height' the height necessary to show | 6126 | ;; Make `desired-height' the height necessary to show |
| 5967 | ;; all of WINDOW's buffer, constrained by MIN-HEIGHT | 6127 | ;; all of WINDOW's buffer, constrained by MIN-HEIGHT |
| @@ -6024,89 +6184,7 @@ WINDOW was scrolled." | |||
| 6024 | (window-resize window 1 nil window) | 6184 | (window-resize window 1 nil window) |
| 6025 | (setq desired-height (1+ desired-height))))) | 6185 | (setq desired-height (1+ desired-height))))) |
| 6026 | (error (setq delta nil))) | 6186 | (error (setq delta nil))) |
| 6027 | delta)))) | 6187 | delta))))) |
| 6028 | |||
| 6029 | (defcustom fit-frame-to-buffer-bottom-margin 4 | ||
| 6030 | "Bottom margin for `fit-frame-to-buffer'. | ||
| 6031 | This is the number of lines `fit-frame-to-buffer' leaves free at the | ||
| 6032 | bottom of the display in order to not obscure the system task bar." | ||
| 6033 | :type 'integer | ||
| 6034 | :version "24.2" | ||
| 6035 | :group 'windows) | ||
| 6036 | |||
| 6037 | (defun fit-frame-to-buffer (&optional frame max-height min-height) | ||
| 6038 | "Adjust height of FRAME to display its buffer's contents exactly. | ||
| 6039 | FRAME can be any live frame and defaults to the selected one. | ||
| 6040 | |||
| 6041 | Optional argument MAX-HEIGHT specifies the maximum height of | ||
| 6042 | FRAME and defaults to the height of the display below the current | ||
| 6043 | top line of FRAME minus FIT-FRAME-TO-BUFFER-BOTTOM-MARGIN. | ||
| 6044 | Optional argument MIN-HEIGHT specifies the minimum height of | ||
| 6045 | FRAME." | ||
| 6046 | (interactive) | ||
| 6047 | (setq frame (window-normalize-frame frame)) | ||
| 6048 | (let* ((root (frame-root-window frame)) | ||
| 6049 | (frame-min-height | ||
| 6050 | (+ (- (frame-height frame) (window-total-size root)) | ||
| 6051 | window-min-height)) | ||
| 6052 | (frame-top (frame-parameter frame 'top)) | ||
| 6053 | (top (if (consp frame-top) | ||
| 6054 | (funcall (car frame-top) (cadr frame-top)) | ||
| 6055 | frame-top)) | ||
| 6056 | (frame-max-height | ||
| 6057 | (- (/ (- (x-display-pixel-height frame) top) | ||
| 6058 | (frame-char-height frame)) | ||
| 6059 | fit-frame-to-buffer-bottom-margin)) | ||
| 6060 | (compensate 0) | ||
| 6061 | delta) | ||
| 6062 | (when (and (window-live-p root) (not (window-size-fixed-p root))) | ||
| 6063 | (with-selected-window root | ||
| 6064 | (cond | ||
| 6065 | ((not max-height) | ||
| 6066 | (setq max-height frame-max-height)) | ||
| 6067 | ((numberp max-height) | ||
| 6068 | (setq max-height (min max-height frame-max-height))) | ||
| 6069 | (t | ||
| 6070 | (error "%s is an invalid maximum height" max-height))) | ||
| 6071 | (cond | ||
| 6072 | ((not min-height) | ||
| 6073 | (setq min-height frame-min-height)) | ||
| 6074 | ((numberp min-height) | ||
| 6075 | (setq min-height (min min-height frame-min-height))) | ||
| 6076 | (t | ||
| 6077 | (error "%s is an invalid minimum height" min-height))) | ||
| 6078 | ;; When tool-bar-mode is enabled and we have just created a new | ||
| 6079 | ;; frame, reserve lines for toolbar resizing. This is needed | ||
| 6080 | ;; because for reasons unknown to me Emacs (1) reserves one line | ||
| 6081 | ;; for the toolbar when making the initial frame and toolbars | ||
| 6082 | ;; are enabled, and (2) later adds the remaining lines needed. | ||
| 6083 | ;; Our code runs IN BETWEEN (1) and (2). YMMV when you're on a | ||
| 6084 | ;; system that behaves differently. | ||
| 6085 | (let ((quit-restore (window-parameter root 'quit-restore)) | ||
| 6086 | (lines (tool-bar-lines-needed frame))) | ||
| 6087 | (when (and quit-restore (eq (car quit-restore) 'frame) | ||
| 6088 | (not (zerop lines))) | ||
| 6089 | (setq compensate (1- lines)))) | ||
| 6090 | (message "%s" compensate) | ||
| 6091 | (setq delta | ||
| 6092 | ;; Always count a final newline - we don't do any | ||
| 6093 | ;; post-processing, so let's play safe. | ||
| 6094 | (+ (count-screen-lines nil nil t) | ||
| 6095 | (- (window-body-size)) | ||
| 6096 | compensate))) | ||
| 6097 | ;; Move away from final newline. | ||
| 6098 | (when (and (eobp) (bolp) (not (bobp))) | ||
| 6099 | (set-window-point root (line-beginning-position 0))) | ||
| 6100 | (set-window-start root (point-min)) | ||
| 6101 | (set-window-vscroll root 0) | ||
| 6102 | (condition-case nil | ||
| 6103 | (set-frame-height | ||
| 6104 | frame | ||
| 6105 | (min (max (+ (frame-height frame) delta) | ||
| 6106 | min-height) | ||
| 6107 | max-height)) | ||
| 6108 | (error (setq delta nil)))) | ||
| 6109 | delta)) | ||
| 6110 | 6188 | ||
| 6111 | (defun window-safely-shrinkable-p (&optional window) | 6189 | (defun window-safely-shrinkable-p (&optional window) |
| 6112 | "Return t if WINDOW can be shrunk without shrinking other windows. | 6190 | "Return t if WINDOW can be shrunk without shrinking other windows. |
diff --git a/src/ChangeLog b/src/ChangeLog index e07f7e131cb..12992f1de0a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-09-30 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.c (Vwindow_combination_limit): New default value. | ||
| 4 | (Qwindow_size): New symbol replacing Qtemp_buffer_resize. | ||
| 5 | |||
| 1 | 2012-09-30 Paul Eggert <eggert@cs.ucla.edu> | 6 | 2012-09-30 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 7 | ||
| 3 | * syssignal.h (PROFILER_CPU_SUPPORT): Don't define if PROFILING. | 8 | * syssignal.h (PROFILER_CPU_SUPPORT): Don't define if PROFILING. |
| @@ -131,6 +136,7 @@ | |||
| 131 | (redisplay_internal): Record itself in backtrace_list. | 136 | (redisplay_internal): Record itself in backtrace_list. |
| 132 | (syms_of_xdisp): Define Qautomatic_redisplay. | 137 | (syms_of_xdisp): Define Qautomatic_redisplay. |
| 133 | 138 | ||
| 139 | 2012-09-25 Eli Zaretskii <eliz@gnu.org> | ||
| 134 | 2012-09-25 Juanma Barranquero <lekktu@gmail.com> | 140 | 2012-09-25 Juanma Barranquero <lekktu@gmail.com> |
| 135 | 141 | ||
| 136 | * makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies. | 142 | * makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies. |
diff --git a/src/window.c b/src/window.c index 86f86deedb2..bb3b73f9acd 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -60,7 +60,7 @@ static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; | |||
| 60 | static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; | 60 | static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; |
| 61 | static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; | 61 | static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; |
| 62 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; | 62 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; |
| 63 | static Lisp_Object Qsafe, Qabove, Qbelow, Qtemp_buffer_resize, Qclone_of; | 63 | static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of; |
| 64 | 64 | ||
| 65 | static int displayed_window_lines (struct window *); | 65 | static int displayed_window_lines (struct window *); |
| 66 | static int count_windows (struct window *); | 66 | static int count_windows (struct window *); |
| @@ -6704,7 +6704,7 @@ syms_of_window (void) | |||
| 6704 | DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows"); | 6704 | DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows"); |
| 6705 | DEFSYM (Qrecord_window_buffer, "record-window-buffer"); | 6705 | DEFSYM (Qrecord_window_buffer, "record-window-buffer"); |
| 6706 | DEFSYM (Qget_mru_window, "get-mru-window"); | 6706 | DEFSYM (Qget_mru_window, "get-mru-window"); |
| 6707 | DEFSYM (Qtemp_buffer_resize, "temp-buffer-resize"); | 6707 | DEFSYM (Qwindow_size, "window-size"); |
| 6708 | DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); | 6708 | DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); |
| 6709 | DEFSYM (Qabove, "above"); | 6709 | DEFSYM (Qabove, "above"); |
| 6710 | DEFSYM (Qbelow, "below"); | 6710 | DEFSYM (Qbelow, "below"); |
| @@ -6804,19 +6804,19 @@ This variable takes no effect if `window-combination-limit' is non-nil. */); | |||
| 6804 | The following values are recognized: | 6804 | The following values are recognized: |
| 6805 | 6805 | ||
| 6806 | nil means splitting a window will create a new parent window only if the | 6806 | nil means splitting a window will create a new parent window only if the |
| 6807 | window has no parent window or the window shall become a combination | 6807 | window has no parent window or the window shall become part of a |
| 6808 | orthogonal to the one it is part of. | 6808 | combination orthogonal to the one it is part of. |
| 6809 | 6809 | ||
| 6810 | `temp-buffer-resize' means that splitting a window for displaying a | 6810 | `window-size' means that splitting a window for displaying a buffer |
| 6811 | temporary buffer makes a new parent window provided | 6811 | makes a new parent window provided `display-buffer' is supposed to |
| 6812 | `temp-buffer-resize-mode' is enabled. Otherwise, this value is | 6812 | explicitly set the window's size due to the presence of a |
| 6813 | handled like nil. | 6813 | `window-height' or `window-width' entry in the alist used by |
| 6814 | `display-buffer'. Otherwise, this value is handled like nil. | ||
| 6814 | 6815 | ||
| 6815 | `temp-buffer' means that splitting a window for displaying a temporary | 6816 | `temp-buffer' means that splitting a window for displaying a temporary |
| 6816 | buffer always makes a new parent window. Otherwise, this value is | 6817 | buffer always makes a new parent window. Otherwise, this value is |
| 6817 | handled like nil. | 6818 | handled like nil. |
| 6818 | 6819 | ||
| 6819 | |||
| 6820 | `display-buffer' means that splitting a window for displaying a buffer | 6820 | `display-buffer' means that splitting a window for displaying a buffer |
| 6821 | always makes a new parent window. Since temporary buffers are | 6821 | always makes a new parent window. Since temporary buffers are |
| 6822 | displayed by the function `display-buffer', this value is stronger | 6822 | displayed by the function `display-buffer', this value is stronger |
| @@ -6829,7 +6829,7 @@ t means that splitting a window always creates a new parent window. If | |||
| 6829 | sibling. | 6829 | sibling. |
| 6830 | 6830 | ||
| 6831 | Other values are reserved for future use. */); | 6831 | Other values are reserved for future use. */); |
| 6832 | Vwindow_combination_limit = Qtemp_buffer_resize; | 6832 | Vwindow_combination_limit = Qwindow_size; |
| 6833 | 6833 | ||
| 6834 | DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, | 6834 | DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, |
| 6835 | doc: /* Alist of persistent window parameters. | 6835 | doc: /* Alist of persistent window parameters. |