Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
9adf1f06
Commit
9adf1f06
authored
Dec 12, 2008
by
Martin Rudalics
Browse files
(fit-window-to-buffer): Return non-nil when height
was orderly adjusted, nil otherwise.
parent
21c58e4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
lisp/ChangeLog
lisp/ChangeLog
+5
-0
lisp/window.el
lisp/window.el
+10
-4
No files found.
lisp/ChangeLog
View file @
9adf1f06
2008-12-12 Martin Rudalics <rudalics@gmx.at>
* window.el (fit-window-to-buffer): Return non-nil when height
was orderly adjusted, nil otherwise.
2008-12-12 Juanma Barranquero <lekktu@gmail.com>
Stefan Monnier <monnier@iro.umontreal.ca>
...
...
lisp/window.el
View file @
9adf1f06
...
...
@@ -1294,7 +1294,7 @@ in some window."
(defun fit-window-to-buffer (&optional window max-height min-height)
"
Adjust
height
of
WINDOW
to
display
its
buffer
's
contents
exactly.
WINDOW
defaults
to
the
selected
window.
Return
nil.
WINDOW
defaults
to
the
selected
window.
Optional
argument
MAX-HEIGHT
specifies
the
maximum
height
of
the
window
and
defaults
to
the
maximum
permissible
height
of
a
window
on
WINDOW
's
frame.
...
...
@@ -1303,12 +1303,15 @@ window 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.
Return
non-nil
if
height
was
orderly
adjusted,
nil
otherwise.
Caution:
This
function
can
delete
WINDOW
and/or
other
windows
when
their
height
shrinks
to
less
than
MIN-HEIGHT.
"
(interactive)
;; Do all the work in WINDOW and its buffer and restore the selected
;; window and the current buffer when we're done.
(let ((old-buffer (current-buffer)))
(let ((old-buffer (current-buffer))
value)
(with-selected-window (or window (setq window (selected-window)))
(set-buffer (window-buffer))
;; Use `condition-case' to handle any fixed-size windows and other
...
...
@@ -1384,10 +1387,13 @@ when their height shrinks to less than MIN-HEIGHT."
(= desired-height (window-height))
(not (pos-visible-in-window-p end)))
(enlarge-window 1)
(setq desired-height (1+ desired-height))))))
(setq desired-height (1+ desired-height))))
;; Return non-nil only if nothing "
bad
" happened.
(setq value t)))
(error nil)))
(when (buffer-live-p old-buffer)
(set-buffer old-buffer))))
(set-buffer old-buffer))
value))
(defun window-safely-shrinkable-p (&optional window)
"
Return
t
if
WINDOW
can
be
shrunk
without
shrinking
other
windows.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment