Function: reftex-enlarge-to-fit

reftex-enlarge-to-fit is a byte-compiled function defined in reftex.el.gz.

Signature

(reftex-enlarge-to-fit BUF2 &optional KEEP-CURRENT)

Documentation

Enlarge other window displaying buffer to show whole buffer if possible.

If KEEP-CURRENT in non-nil, current buffer must remain visible.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex.el.gz
(defun reftex-enlarge-to-fit (buf2 &optional keep-current)
  "Enlarge other window displaying buffer to show whole buffer if possible.
If KEEP-CURRENT in non-nil, current buffer must remain visible."
  (let* ((win1 (selected-window))
         (buf1 (current-buffer))
         (win2 (get-buffer-window buf2))) ;; Only on current frame.
    (when win2
      (select-window win2)
      (unless (and (pos-visible-in-window-p (point-min))
                   (pos-visible-in-window-p (point-max)))
        (enlarge-window (1+ (- (count-lines (point-min) (point-max))
                               (window-height))))))
    (cond
     ((window-live-p win1) (select-window win1))
     (keep-current
      ;; we must have the old buffer!
      (switch-to-buffer-other-window buf1)
      (shrink-window (- (window-height) window-min-height))))))