aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2008-12-11 09:48:08 +0000
committerMartin Rudalics2008-12-11 09:48:08 +0000
commitd7e781879d0b4ba2aa36a4c4b39e2846904b290f (patch)
treeddb51c2e8bf575c3781e36748b9b3efdfc0083bc
parent011a014396e59cb621470309ff7865e3972a2953 (diff)
downloademacs-d7e781879d0b4ba2aa36a4c4b39e2846904b290f.tar.gz
emacs-d7e781879d0b4ba2aa36a4c4b39e2846904b290f.zip
(dired-pop-to-buffer): Use fit-window-to-buffer when
dired-shrink-to-fit is non-nil. (Bug#1488)
-rw-r--r--lisp/dired.el40
1 files changed, 3 insertions, 37 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index 8e1d574b270..5d0db7ecc1d 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2678,44 +2678,10 @@ name, or the marker and a count of marked files."
2678 2678
2679(defun dired-pop-to-buffer (buf) 2679(defun dired-pop-to-buffer (buf)
2680 ;; Pop up buffer BUF. 2680 ;; Pop up buffer BUF.
2681 (pop-to-buffer (get-buffer-create buf))
2681 ;; If dired-shrink-to-fit is t, make its window fit its contents. 2682 ;; If dired-shrink-to-fit is t, make its window fit its contents.
2682 (if (not dired-shrink-to-fit) 2683 (when dired-shrink-to-fit
2683 (pop-to-buffer (get-buffer-create buf)) 2684 (fit-window-to-buffer (get-buffer-window buf))))
2684 ;; let window shrink to fit:
2685 (let ((window (selected-window))
2686 target-lines w2)
2687 (cond ;; if split-height-threshold is enabled, use the largest window
2688 ((and (> (window-height (setq w2 (get-largest-window)))
2689 split-height-threshold)
2690 (window-full-width-p w2))
2691 (setq window w2))
2692 ;; if the least-recently-used window is big enough, use it
2693 ((and (> (window-height (setq w2 (get-lru-window)))
2694 (* 2 window-min-height))
2695 (window-full-width-p w2))
2696 (setq window w2)))
2697 (save-excursion
2698 (set-buffer buf)
2699 (goto-char (point-max))
2700 (skip-chars-backward "\n\r\t ")
2701 (setq target-lines (count-lines (point-min) (point)))
2702 ;; Don't forget to count the last line.
2703 (if (not (bolp))
2704 (setq target-lines (1+ target-lines))))
2705 (if (<= (window-height window) (* 2 window-min-height))
2706 ;; At this point, every window on the frame is too small to split.
2707 (setq w2 (display-buffer buf))
2708 (setq w2 (split-window window
2709 (max window-min-height
2710 (- (window-height window)
2711 (1+ (max window-min-height target-lines)))))))
2712 (set-window-buffer w2 buf)
2713 (if (< (1- (window-height w2)) target-lines)
2714 (progn
2715 (select-window w2)
2716 (enlarge-window (- target-lines (1- (window-height w2))))))
2717 (set-window-start w2 1)
2718 )))
2719 2685
2720(defcustom dired-no-confirm nil 2686(defcustom dired-no-confirm nil
2721 "A list of symbols for commands Dired should not confirm. 2687 "A list of symbols for commands Dired should not confirm.