Commit 47f730e3 authored by Martin Rudalics's avatar Martin Rudalics

Add code for "preserving" window sizes.

* frame.c (frame_windows_min_size): New argument IGNORE.
(adjust_frame_size): When called from change_frame_size call
frame_windows_min_size with IGNORE Qt so we can ignore size
restrictions.

* dired.el (dired-pop-to-buffer): Call fit-window-to-buffer with
`preserve-size' t.
(dired-mark-pop-up): Preserve size of window showing marked
files.
* electric.el (Electric-pop-up-window):
* help.el (resize-temp-buffer-window): Call fit-window-to-buffer
with `preserve-size' t.
* minibuffer.el (minibuffer-completion-help): Use
`resize-temp-buffer-window' instead of `fit-window-to-buffer'
(Bug#19355).  Preserve size of completions window.
* register.el (register-preview): Preserve size of register
preview window.
* tmm.el (tmm-add-prompt): Call fit-window-to-buffer
with `preserve-size' t (Bug#1291).
* window.el (with-displayed-buffer-window): Add calls to
`window-preserve-size'.
(window-min-pixel-size, window--preservable-size)
(window-preserve-size, window-preserved-size)
(window--preserve-size, window--min-size-ignore-p): New
functions.
(window-min-size, window-min-delta, window--resizable)
(window--resize-this-window, split-window-below)
(split-window-right): Amend doc-string.
(adjust-window-trailing-edge): Handle preserving window
sizes.  Signal user-error instead of an error when there's no
window above or below.
(window--min-size-1, window-sizable, window--size-fixed-1)
(window-size-fixed-p, window--min-delta-1)
(frame-windows-min-size, window--max-delta-1, window-resize)
(window--resize-child-windows, window--resize-siblings)
(enlarge-window, shrink-window, split-window): Handle preserving
window sizes.
(window--state-put-2): Handle horizontal scroll bars.
(window--display-buffer): Call `preserve-size' if asked for.
(display-buffer): Mention `preserve-size' alist member in
doc-string.
(fit-window-to-buffer): New argument PRESERVE-SIZE.
parent 36c43e95
......@@ -575,6 +575,10 @@ fullwidth frames, the behavior may depend on the toolkit used.
specific frame does not resize that frame in order to preserve the
number of columns or lines it displays.
** New function `window-preserve-size' allows to preserve the size of
windows without "fixing" it. It's supported by `fit-window-to-buffer',
`temp-buffer-resize-mode' and `display-buffer'.
** Tearoff menus and detachable toolbars for Gtk+ has been removed.
Those features have been deprecated in Gtk+ for a long time.
......
2014-12-18 Martin Rudalics <rudalics@gmx.at>
Add code for "preserving" window sizes.
* dired.el (dired-pop-to-buffer): Call fit-window-to-buffer with
`preserve-size' t.
(dired-mark-pop-up): Preserve size of window showing marked
files.
* electric.el (Electric-pop-up-window):
* help.el (resize-temp-buffer-window): Call fit-window-to-buffer
with `preserve-size' t.
* minibuffer.el (minibuffer-completion-help): Use
`resize-temp-buffer-window' instead of `fit-window-to-buffer'
(Bug#19355). Preserve size of completions window.
* register.el (register-preview): Preserve size of register
preview window.
* tmm.el (tmm-add-prompt): Call fit-window-to-buffer
with `preserve-size' t (Bug#1291).
* window.el (with-displayed-buffer-window): Add calls to
`window-preserve-size'.
(window-min-pixel-size, window--preservable-size)
(window-preserve-size, window-preserved-size)
(window--preserve-size, window--min-size-ignore-p): New
functions.
(window-min-size, window-min-delta, window--resizable)
(window--resize-this-window, split-window-below)
(split-window-right): Amend doc-string.
(window--min-size-1, window-sizable, window--size-fixed-1)
(window-size-fixed-p, window--min-delta-1)
(frame-windows-min-size, window--max-delta-1, window-resize)
(window--resize-child-windows, window--resize-siblings)
(enlarge-window, shrink-window, split-window): Handle preserving
window sizes.
(adjust-window-trailing-edge): Handle preserving window
sizes. Signal user-error instead of an error when there's no
window above or below.
(window--state-put-2): Handle horizontal scroll bars.
(window--display-buffer): Call `preserve-size' if asked for.
(display-buffer): Mention `preserve-size' alist member in
doc-string.
(fit-window-to-buffer): New argument PRESERVE-SIZE.
2014-12-18 Dmitry Gutov <dgutov@yandex.ru>
* emacs-lisp/package.el (package-activate): Do not re-activate or
......
......@@ -3059,7 +3059,7 @@ or \"* [3 files]\"."
(when dired-shrink-to-fit
;; Try to not delete window when we want to display less than
;; `window-min-height' lines.
(fit-window-to-buffer (get-buffer-window buf) nil 1)))
(fit-window-to-buffer (get-buffer-window buf) nil 1 nil nil t)))
(defcustom dired-no-confirm nil
"A list of symbols for commands Dired should not confirm, or t.
......@@ -3106,7 +3106,8 @@ argument or confirmation)."
(with-displayed-buffer-window
buffer
(cons 'display-buffer-below-selected
'((window-height . fit-window-to-buffer)))
'((window-height . fit-window-to-buffer)
(preserve-size . (nil . t))))
#'(lambda (window _value)
(with-selected-window window
(unwind-protect
......
......@@ -164,7 +164,10 @@
;; Don't shrink the window, but expand it if necessary.
(goto-char (point-min))
(unless (= (point-max) (window-end win t))
(fit-window-to-buffer win max-height))
;; This call is executed even if the window existed before, was
;; reused, ... contradicting a claim in the comment before this
;; function.
(fit-window-to-buffer win max-height nil nil nil t))
win)))
;;; Electric keys.
......
......@@ -1133,7 +1133,10 @@ of a horizontal combination, restrain its new size by
`fit-window-to-buffer-horizontally' can inhibit resizing.
If WINDOW is the root window of its frame, resize the frame
provided `fit-frame-to-buffer' is non-nil."
provided `fit-frame-to-buffer' is non-nil.
This function may call `preserve-window-size' to preserve the
size of WINDOW."
(setq window (window-normalize-window window t))
(let ((height (if (functionp temp-buffer-max-height)
(with-selected-window window
......@@ -1155,7 +1158,7 @@ provided `fit-frame-to-buffer' is non-nil."
(and (eq quit-cadr 'frame)
fit-frame-to-buffer
(eq window (frame-root-window window))))
(fit-window-to-buffer window height nil width))))
(fit-window-to-buffer window height nil width nil t))))
;;; Help windows.
(defcustom help-window-select nil
......
......@@ -1818,7 +1818,10 @@ variables.")
,(if (eq (selected-window) (minibuffer-window))
'display-buffer-at-bottom
'display-buffer-below-selected))
(window-height . fit-window-to-buffer))
,(when temp-buffer-resize-mode
'(window-height . resize-temp-buffer-window))
,(when temp-buffer-resize-mode
'(preserve-size . (nil . t))))
nil
;; Remove the base-size tail because `sort' requires a properly
;; nil-terminated list.
......
......@@ -135,7 +135,8 @@ Format of each entry is controlled by the variable `register-preview-function'."
(with-current-buffer-window
buffer
(cons 'display-buffer-below-selected
'((window-height . fit-window-to-buffer)))
'((window-height . fit-window-to-buffer)
(preserve-size . (nil . t))))
nil
(with-current-buffer standard-output
(setq cursor-in-non-selected-windows nil)
......
......@@ -371,7 +371,6 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
(unless tmm-c-prompt
(error "No active menu entries"))
(setq tmm-old-mb-map (tmm-define-keys t))
;; Get window and hide it for electric mode to get correct size
(or tmm-completion-prompt
(add-hook 'completion-setup-hook
'tmm-completion-delete-prompt 'append))
......@@ -381,9 +380,15 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
(with-current-buffer "*Completions*"
(tmm-remove-inactive-mouse-face)
(when tmm-completion-prompt
(let ((inhibit-read-only t))
(let ((inhibit-read-only t)
(window (get-buffer-window "*Completions*")))
(goto-char (point-min))
(insert tmm-completion-prompt))))
(insert tmm-completion-prompt)
(when window
;; Try to show everything just inserted and preserve height of
;; *Completions* window. This should fix a behavior described
;; in Bug#1291.
(fit-window-to-buffer window nil nil nil nil t)))))
(insert tmm-c-prompt))
(defun tmm-shortcut ()
......
This diff is collapsed.
2014-12-18 Martin Rudalics <rudalics@gmx.at>
* frame.c (frame_windows_min_size): New argument IGNORE.
(adjust_frame_size): When called from change_frame_size call
frame_windows_min_size with IGNORE Qt so we can ignore size
restrictions.
2014-12-18 Eli Zaretskii <eliz@gnu.org>
* font.c (Ffont_info): Add more font information to the vector
......
......@@ -335,9 +335,9 @@ predicates which report frame's specific UI-related capabilities. */)
}
static int
frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, Lisp_Object pixelwise)
frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, Lisp_Object ignore, Lisp_Object pixelwise)
{
return XINT (call3 (Qframe_windows_min_size, frame, horizontal, pixelwise));
return XINT (call4 (Qframe_windows_min_size, frame, horizontal, ignore, pixelwise));
}
......@@ -419,8 +419,10 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
/* The following two values are calculated from the old window body
sizes and any "new" settings for scroll bars, dividers, fringes and
margins (though the latter should have been processed already). */
min_windows_width = frame_windows_min_size (frame, Qt, Qt);
min_windows_height = frame_windows_min_size (frame, Qnil, Qt);
min_windows_width
= frame_windows_min_size (frame, Qt, (inhibit == 5) ? Qt : Qnil, Qt);
min_windows_height
= frame_windows_min_size (frame, Qnil, (inhibit == 5) ? Qt : Qnil, Qt);
if (inhibit >= 2 && inhibit <= 4)
/* If INHIBIT is in [2..4] inhibit if the "old" window sizes stay
......
......@@ -4135,11 +4135,7 @@ values. */)
/* Resize frame F's windows when number of lines of F is set to SIZE.
HORFLAG 1 means resize windows when number of columns of F is set to
SIZE. PIXELWISE 1 means to interpret SIZE as pixels.
This function can delete all windows but the selected one in order to
satisfy the request. The result will be meaningful if and only if
F's windows have meaningful sizes when you call this. */
SIZE. PIXELWISE 1 means to interpret SIZE as pixels. */
void
resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment