Commit cac0a1d6 authored by Martin Rudalics's avatar Martin Rudalics

More window code related fixes and documentation changes.

* window.c (Fother_window_for_scrolling): Check that
Vother_window_scroll_buffer is a buffer.
* window.el (fit-frame-to-buffer, fit-frame-to-buffer-margins):
Fix doc-strings.
(fit-frame-to-buffer): New argument ONLY.  Remove dependency on
fit-frame-to-buffer variable.  Fix doc-string.
(fit-window-to-buffer): Set ONLY argument in call of
fit-frame-to-buffer.  Fix doc-string.
* frames.texi (Size and Position): Rewrite entries for
`fit-frame-to-buffer' and `fit-frame-to-buffer-margins'.  Add
description for `fit-frame-to-buffer-sizes'.
* windows.texi (Resizing Windows): Add descriptions for
pixelwise resizing.  Add entries for `window-resize-pixelwise'
and `fit-window-to-buffer-horizontally'.  Rewrite
`fit-window-to-buffer' entry.
parent fa965cbf
2014-03-06 Martin Rudalics <rudalics@gmx.at>
* frames.texi (Size and Position): Rewrite entries for
`fit-frame-to-buffer' and `fit-frame-to-buffer-margins'. Add
description for `fit-frame-to-buffer-sizes'.
* windows.texi (Resizing Windows): Add descriptions for
pixelwise resizing. Add entries for `window-resize-pixelwise'
and `fit-window-to-buffer-horizontally'. Rewrite
`fit-window-to-buffer' entry.
2014-03-06 Xue Fuqiao <xfq@gnu.org>
* internals.texi (Window Internals): Remove field `region_showing'.
......
......@@ -1180,19 +1180,48 @@ The argument @var{pretend} has the same meaning as in
@c FIXME? Belongs more in Emacs manual than here?
@c But, e.g., fit-window-to-buffer is in this manual.
@deffn Command fit-frame-to-buffer &optional frame max-height min-height
This command adjusts the height of @var{frame} (the default is the
selected frame) to fit its contents. The optional arguments
@var{max-height} and @var{min-height} specify the maximum and minimum
new frame heights, respectively.
@vindex fit-frame-to-buffer-bottom-margin
The default minimum height corresponds to @code{window-min-height}.
The default maximum height is the screen height below the current top
position of the frame, minus any margin specified by the option
@code{fit-frame-to-buffer-bottom-margin}.
If you have a frame that displays only one window, you can fit that
frame to its buffer using the command @code{fit-frame-to-buffer}.
@deffn Command fit-frame-to-buffer &optional frame max-height min-height max-width min-width only
This command adjusts the size of @var{frame} to display the contents of
its buffer exactly. @var{frame} can be any live frame and defaults to
the selected one. Fitting is done only if @var{frame}'s root window is
live. The arguments @var{max-height}, @var{min-height}, @var{max-width}
and @var{min-width} specify bounds on the new total size of
@var{frame}'s root window. @var{min-height} and @var{min-width} default
to the values of @code{window-min-height} and @code{window-min-width}
respectively.
If the optional argument @var{only} is @code{vertically}, this function
may resize the frame vertically only. If @var{only} is
@code{horizontally}, it may resize the frame horizontally only.
@end deffn
The behavior of @code{fit-frame-to-buffer} can be controlled with the
help of the two options listed next.
@defopt fit-frame-to-buffer-margins
This option can be used to specify margins around frames to be fit by
@code{fit-frame-to-buffer}. Such margins can be useful to avoid, for
example, that such frames overlap the taskbar.
It specifies the numbers of pixels to be left free on the left, above,
the right, and below a frame that shall be fit. The default specifies
@code{nil} for each which means to use no margins. The value specified
here can be overridden for a specific frame by that frame's
@code{fit-frame-to-buffer-margins} parameter, if present.
@end defopt
@defopt fit-frame-to-buffer-sizes
This option specifies size boundaries for @code{fit-frame-to-buffer}.
It specifies the total maximum and minimum lines and maximum and minimum
columns of the root window of any frame that shall be fit to its buffer.
If any of these values is non-@code{nil}, it overrides the corresponding
argument of @code{fit-frame-to-buffer}.
@end defopt
@node Geometry
@subsection Geometry
......
......@@ -691,10 +691,9 @@ lines or columns. If @var{delta} is non-zero, a return value of 0 means
that the window cannot be resized.
Normally, the variables @code{window-min-height} and
@code{window-min-width} specify the smallest allowable window size.
@xref{Change Window,, Deleting and Rearranging Windows, emacs, The GNU
Emacs Manual}. However, if the optional argument @var{ignore} is
non-@code{nil}, this function ignores @code{window-min-height} and
@code{window-min-width} specify the smallest allowable window size
(@pxref{Window Sizes}). However, if the optional argument @var{ignore}
is non-@code{nil}, this function ignores @code{window-min-height} and
@code{window-min-width}, as well as @code{window-size-fixed}. Instead,
it considers the minimum-height window to be one consisting of a header,
a mode line and a bottom divider (if any), plus a text area one line
......@@ -755,43 +754,73 @@ window is fixed-size), it may resize other windows.
@cindex pixelwise, resizing windows
@defopt window-resize-pixelwise
If the value of this user option is non-@code{nil}, window resizing
operations will be pixelwise. This currently affects the following
functions: @code{split-window}, @code{maximize-window},
@code{minimize-window}, @code{fit-window-to-buffer} and
@code{fit-frame-to-buffer}, and all functions that symmetrically
resize a parent window.
If the value of this option is non-@code{nil}, windows are resized in
units of pixels. This currently affects functions like
@code{split-window} (@pxref{Splitting Windows}), @code{maximize-window},
@code{minimize-window}, @code{fit-window-to-buffer},
@code{shrink-window-if-larger-than-buffer} (all listed below) and
@code{fit-frame-to-buffer} (@pxref{Size and Position}).
Note that when a frame's pixel size is not a multiple of the frame's
character size, at least one window may get resized pixelwise even if
this option is nil. The default value of this user option is
this option is @code{nil}. The default value of this option is
@code{nil}.
@end defopt
The following commands resize windows in more specific ways. When
called interactively, they act on the selected window.
@deffn Command fit-window-to-buffer &optional window max-height min-height override
This command adjusts the height of @var{window} to fit the text in it.
It returns non-@code{nil} if it was able to resize @var{window}, and
@code{nil} otherwise. If @var{window} is omitted or @code{nil}, it
defaults to the selected window. Otherwise, it should be a live
window.
@deffn Command fit-window-to-buffer &optional window max-height min-height max-width min-width
This command adjusts the height or width of @var{window} to fit the text
in it. It returns non-@code{nil} if it was able to resize @var{window},
and @code{nil} otherwise. If @var{window} is omitted or @code{nil}, it
defaults to the selected window. Otherwise, it should be a live window.
If @var{window} is part of a vertical combination, this function adjusts
@var{window}'s height. The new height is calculated from the actual
height of the accessible portion of its buffer. The optional argument
@var{max-height}, if non-@code{nil}, specifies the maximum total height
that this function can give @var{window}. The optional argument
@var{min-height}, if non-@code{nil}, specifies the minimum total height
that it can give, which overrides the variable @code{window-min-height}.
Both @var{max-height} and @var{min-height} are specified in lines and
include mode and header line and a bottom divider, if any.
If @var{window} is part of a horizontal combination and the value of the
option @code{fit-window-to-buffer-horizontally} (see below) is
non-@code{nil}, this function adjusts @var{window}'s height. The new
width of @var{window} is calculated from the maximum length of its
buffer's lines that follow the current start position of @var{window}.
The optional argument @var{max-width} specifies a maximum width and
defaults to the width of @var{window}'s frame. The optional argument
@var{min-width} specifies a minimum width and defaults to
@code{window-min-width}. Both @var{max-width} and @var{min-width} are
specified in columns and include fringes, margins and scrollbars, if
any.
The optional argument @var{max-height}, if non-@code{nil}, specifies
the maximum total height that this function can give @var{window}.
The optional argument @var{min-height}, if non-@code{nil}, specifies
the minimum total height that it can give, which overrides the
variable @code{window-min-height}.
If the option @code{fit-frame-to-buffer} (see below) is non-@code{nil},
this function will try to resize the frame of @var{window} to fit its
contents by calling @code{fit-frame-to-buffer} (@pxref{Size and
Position}).
@end deffn
If the optional argument @var{override} is non-@code{nil}, this
function ignores any size restrictions imposed by
@code{window-min-height} and @code{window-min-width}.
@defopt fit-window-to-buffer-horizontally
If this is non-@code{nil}, @code{fit-window-to-buffer} can resize
windows horizontally. If this is @code{nil} (the default)
@code{fit-window-to-buffer} never resizes windows horizontally. If this
is @code{only}, it can resize windows horizontally only. Any other
value means @code{fit-window-to-buffer} can resize windows in both
dimensions.
@end defopt
@vindex fit-frame-to-buffer
If the option @code{fit-frame-to-buffer} is non-@code{nil}, this
command may resize the frame to fit its contents.
@end deffn
@defopt fit-frame-to-buffer
If this option is non-@code{nil}, @code{fit-window-to-buffer} can fit a
frame to its buffer. A frame is fit if and only if its root window is a
live window and this option is non-@code{nil}. If this is
@code{horizontally}, frames are fit horizontally only. If this is
@code{vertically}, frames are fit vertically only. Any other
non-@code{nil} value means frames can be resized in both dimensions.
@end defopt
@deffn Command shrink-window-if-larger-than-buffer &optional window
This command attempts to reduce @var{window}'s height as much as
......@@ -804,8 +833,12 @@ it should be a live window.
This command does nothing if the window is already too short to
display all of its buffer, or if any of the buffer is scrolled
off-screen, or if the window is the only live window in its frame.
This command calls @code{fit-window-to-buffer} (see above) to do its
work.
@end deffn
@cindex balancing window sizes
@deffn Command balance-windows &optional window-or-frame
This function balances windows in a way that gives more space to
......
......@@ -226,6 +226,11 @@ resize windows pixelwise. Most functions for changing or accessing
window sizes now have an additional argument that allows changes to apply,
or values to be returned, in pixels instead of lines/columns.
+++
*** The functions `window-body-height' and `window-body-width' now never
count partially visible lines or columns if called with a nil PIXELWISE
argument.
*** Emacs can now draw dividers between adjacent windows. To put
dividers between side-by-side/vertically stacked windows customize the
frame parameters `right-divider-width' and `bottom-divider-width' to
......@@ -246,14 +251,13 @@ text of a window's buffer in pixels. This allows functions like
`fit-frame-to-buffer' and `fit-window-to-buffer' to accurately fit a
window to its buffer as it will be displayed.
*** `fit-window-to-buffer' can now resize windows horizontally.
*** `fit-window-to-buffer' can now resize windows in both dimensions.
This behavior is controlled by the new option
`fit-window-to-buffer-horizontally'.
`fit-window-to-buffer-horizontally'. The new option
`fit-frame-to-buffer' allows to fit the window's frame to its buffer.
*** `fit-frame-to-buffer' can now fit frames in both directions.
This behavior is controlled by the option `fit-frame-to-buffer' which
tells in which direction(s) the frame shall be fit. The new options
`fit-frame-to-buffer-margins' and `fit-frame-to-buffer-sizes' allow to
*** `fit-frame-to-buffer' now fits frames in both dimensions. The new
options `fit-frame-to-buffer-margins' and `fit-frame-to-buffer-sizes'
control the size of the frame and its position on screen.
*** Temp Buffer Resize Mode can now adjust height and width of windows
......
2014-03-06 Martin Rudalics <rudalics@gmx.at>
* window.el (fit-frame-to-buffer, fit-frame-to-buffer-margins):
Fix doc-strings.
(fit-frame-to-buffer): New argument ONLY. Remove dependency on
fit-frame-to-buffer variable. Fix doc-string.
(fit-window-to-buffer): Set ONLY argument in call of
fit-frame-to-buffer. Fix doc-string.
2014-03-06 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-error): VEC-OR-PROC can be nil.
......
......@@ -6813,34 +6813,27 @@ can resize windows in both dimensions."
;; `fit-frame-to-buffer' eventually wants to know the real frame sizes
;; counting title bar and outer borders.
(defcustom fit-frame-to-buffer nil
"Non-nil means `fit-frame-to-buffer' can fit a frame to its buffer.
"Non-nil means `fit-window-to-buffer' can fit a frame to its buffer.
A frame is fit if and only if its root window is a live window
and this option is non-nil. If this is `horizontally', frames
are resized horizontally only. If this is `vertically', frames
are resized vertically only. Any other non-nil value means
frames can be resized in both dimensions. See also
`fit-frame-to-buffer-margins' and `fit-frame-to-buffer-sizes'.
If this is non-nil and a window is the only window of its frame,
`fit-window-to-buffer' will invoke `fit-frame-to-buffer' to fit
the frame to its buffer."
frames can be resized in both dimensions."
:type 'boolean
:version "24.4"
:group 'help)
(defcustom fit-frame-to-buffer-margins '(nil nil nil nil)
"Margins around frame for `fit-frame-to-buffer'.
This list specifies the numbers of pixels to be left free on the
left, above, the right, and below a frame that shall be fit to
its buffer. The value specified here can be overridden for a
specific frame by that frame's `fit-frame-to-buffer-margins'
parameter, if present.
This variable controls how fitting a frame to the size of its
buffer coordinates with the size of your display. If you don't
specify a value here, the size of the display's workarea is used.
See also `fit-frame-to-buffer-sizes'."
This option allows to specify the numbers of pixels to be left
free on the left, above, the right, and below a frame that shall
be fit to its buffer. Set these to avoid that such a frame
obscurs other desktop objects like the taskbar. The default is
nil for each side which means to not add any margins.
The value specified here can be overridden for a specific frame
by that frame's `fit-frame-to-buffer-margins' parameter, if
present. See also `fit-frame-to-buffer-sizes'."
:version "24.4"
:type '(list
(choice
......@@ -6917,7 +6910,7 @@ See also `fit-frame-to-buffer-margins'."
(<= left (- right margin)) (<= margin right))
margin))
(defun fit-frame-to-buffer (&optional frame max-height min-height max-width min-width)
(defun fit-frame-to-buffer (&optional frame max-height min-height max-width min-width only)
"Adjust size of FRAME to display the contents of its buffer exactly.
FRAME can be any live frame and defaults to the selected one.
Fit only if FRAME's root window is live. MAX-HEIGHT, MIN-HEIGHT,
......@@ -6925,9 +6918,12 @@ MAX-WIDTH and MIN-WIDTH specify bounds on the new total size of
FRAME's root window. MIN-HEIGHT and MIN-WIDTH default to the values of
`window-min-height' and `window-min-width' respectively.
The option `fit-frame-to-buffer' controls whether this function
has any effect. New position and size of FRAME are additionally
determined by the options `fit-frame-to-buffer-sizes' and
If the optional argument ONLY is `vertically', resize the frame
vertically only. If ONLY is `horizontally', resize the frame
horizontally only.
The new position and size of FRAME can be additionally determined
by customizing the options `fit-frame-to-buffer-sizes' and
`fit-frame-to-buffer-margins' or the corresponding parameters of
FRAME."
(interactive)
......@@ -6936,13 +6932,7 @@ FRAME."
(fboundp 'display-monitor-attributes-list))
(user-error "Cannot resize frame in non-graphic Emacs"))
(setq frame (window-normalize-frame frame))
(when (and (window-live-p (frame-root-window frame))
fit-frame-to-buffer
(or (not window-size-fixed)
(and (eq window-size-fixed 'height)
(not (eq fit-frame-to-buffer 'vertically)))
(and (eq window-size-fixed 'width)
(not (eq fit-frame-to-buffer 'horizontally)))))
(when (window-live-p (frame-root-window frame))
(with-selected-window (frame-root-window frame)
(let* ((window (frame-root-window frame))
(char-width (frame-char-width))
......@@ -7069,11 +7059,11 @@ FRAME."
(width (+ (car value) (window-right-divider-width)))
(height (+ (cdr value) (window-bottom-divider-width))))
;; Don't change height or width when the window's size is fixed
;; in either direction.
;; in either direction or ONLY forbids it.
(cond
((eq window-size-fixed 'width)
((or (eq window-size-fixed 'width) (eq only 'vertically))
(setq width nil))
((eq window-size-fixed 'height)
((or (eq window-size-fixed 'height) (eq only 'horizontally))
(setq height nil)))
;; Fit width to constraints.
(when width
......@@ -7141,13 +7131,13 @@ FRAME."
WINDOW must be a live window and defaults to the selected one.
If WINDOW is part of a vertical combination, adjust WINDOW's
height. The new height is calculated from the number of lines of
height. The new height is calculated from the actual height of
the accessible portion of its buffer. The optional argument
MAX-HEIGHT specifies a maximum height and defaults to the height
of WINDOW's frame. The optional argument MIN-HEIGHT specifies a
minimum height and defaults to `window-min-height'. Both
MAX-HEIGHT and MIN-HEIGHT are specified in lines and include the
mode line and header line, if any.
MAX-HEIGHT and MIN-HEIGHT are specified in lines and include mode
and header line and a bottom divider, if any.
If WINDOW is part of a horizontal combination and the value of
the option `fit-window-to-buffer-horizontally' is non-nil, adjust
......@@ -7157,11 +7147,11 @@ start position of WINDOW. The optional argument MAX-WIDTH
specifies a maximum width and defaults to the width of WINDOW's
frame. The optional argument MIN-WIDTH specifies a minimum width
and defaults to `window-min-width'. Both MAX-WIDTH and MIN-WIDTH
are specified in columns and include fringes, margins and
scrollbars, if any.
are specified in columns and include fringes, margins, a
scrollbar and a vertical divider, if any.
Fit pixelwise if the option `window-resize-pixelwise' is non-nil.
If WINDOW is its frame's root window, then if the option
If WINDOW is its frame's root window and the option
`fit-frame-to-buffer' is non-nil, call `fit-frame-to-buffer' to
adjust the frame's size.
......@@ -7177,7 +7167,9 @@ accessible position."
;; Fit WINDOW's frame to buffer.
(fit-frame-to-buffer
(window-frame window)
max-height min-height max-width min-width))
max-height min-height max-width min-width
(and (memq fit-frame-to-buffer '(vertically horizontally))
fit-frame-to-buffer)))
(with-selected-window window
(let* ((pixelwise window-resize-pixelwise)
(char-height (frame-char-height))
......
2014-03-06 Martin Rudalics <rudalics@gmx.at>
* window.c (Fother_window_for_scrolling): Check that
Vother_window_scroll_buffer is a buffer.
2014-03-06 Dmitry Antipov <dmantipov@yandex.ru>
* xterm.c (xim_initialize): Always pass a copy of resource name
......
......@@ -5431,6 +5431,7 @@ specifies the window. This takes precedence over
window = Vminibuf_scroll_window;
/* If buffer is specified and live, scroll that buffer. */
else if (!NILP (Vother_window_scroll_buffer)
&& BUFFERP (Vother_window_scroll_buffer)
&& BUFFER_LIVE_P (XBUFFER (Vother_window_scroll_buffer)))
{
window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil);
......
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