aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2000-11-16 06:15:55 +0000
committerKenichi Handa2000-11-16 06:15:55 +0000
commitb1491763bb730b84c0d8a846908a9d241921e061 (patch)
tree934a58f9ee6a1f19b44e15fcc5681b2793235969
parent9256a53285ae71252d6c2f93d626d1aeeb51d78b (diff)
downloademacs-b1491763bb730b84c0d8a846908a9d241921e061.tar.gz
emacs-b1491763bb730b84c0d8a846908a9d241921e061.zip
(fit-window-to-buffer): Be sure to acquire at least
one text line even if the buffer is empty.
-rw-r--r--lisp/window.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/window.el b/lisp/window.el
index b6e5c1757d2..59c946ee685 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -456,6 +456,11 @@ header-line."
456 ;; (`count-screen-lines' always works on the current buffer). 456 ;; (`count-screen-lines' always works on the current buffer).
457 (with-current-buffer buf 457 (with-current-buffer buf
458 (+ (count-screen-lines) 458 (+ (count-screen-lines)
459 ;; If the buffer is empty, (count-screen-lines) is
460 ;; zero. But, even in that case, we need one text line
461 ;; for cursor.
462 (if (= (point-min) (point-max))
463 1 0)
459 ;; For non-minibuffers, count the mode-line, if any 464 ;; For non-minibuffers, count the mode-line, if any
460 (if (and (not (window-minibuffer-p window)) 465 (if (and (not (window-minibuffer-p window))
461 mode-line-format) 466 mode-line-format)
@@ -495,11 +500,13 @@ header-line."
495 (1- (point)) 500 (1- (point))
496 (point)))))) 501 (point))))))
497 (set-window-vscroll window 0) 502 (set-window-vscroll window 0)
503 (prog1
504 (list desired-height max-height)
498 (while (and (< desired-height max-height) 505 (while (and (< desired-height max-height)
499 (= desired-height (window-height window)) 506 (= desired-height (window-height window))
500 (not (pos-visible-in-window-p end window t))) 507 (not (pos-visible-in-window-p end window t)))
501 (enlarge-window 1) 508 (enlarge-window 1)
502 (setq desired-height (1+ desired-height))))))) 509 (setq desired-height (1+ desired-height))))))))
503 510
504(defun shrink-window-if-larger-than-buffer (&optional window) 511(defun shrink-window-if-larger-than-buffer (&optional window)
505 "Shrink the WINDOW to be as small as possible to display its contents. 512 "Shrink the WINDOW to be as small as possible to display its contents.