GNU bug report logs -
#55169
Can't combine window-min-height with window-height
Previous Next
Full log
Message #101 received at 55169 <at> debbugs.gnu.org (full text, mbox):
> (defun shrink-window-if-larger-than-buffer (&optional window min-height)
> "Shrink height of WINDOW if its buffer doesn't need so many lines.
> More precisely, shrink WINDOW vertically to be as small as
> possible, while still showing the full contents of its buffer.
> WINDOW must be a live window and defaults to the selected one.
>
> The optional argument MIN-HEIGHT specifies the minimum number of
> lines to which WINDOW may be shrunk and defaults to
> `window-min-height'.
>
> Do nothing if the buffer contains more lines than the present
> height of WINDOW, some of WINDOW's contents are scrolled out of
> view, shrinking WINDOW would also shrink another window, or
> WINDOW is the root window of its frame.
>
> Return non-nil if WINDOW was shrunk, nil otherwise."
> (interactive)
> (setq window (window-normalize-window window t))
> ;; Make sure that WINDOW is vertically combined and `point-min' is
> ;; visible (for whatever reason that's needed). The remaining issues
> ;; should be taken care of by `fit-window-to-buffer'.
> (when (and (window-combined-p window)
> (pos-visible-in-window-p (point-min) window))
> (let ((old-height (window-pixel-height window)))
> (fit-window-to-buffer
> window (window-total-height window) nil min-height)
Thanks, this works fine, after removing nil above.
This bug report was last modified 3 years and 28 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.