From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#1488: 23.0.60; dired-pop-to-buffer: use fit-window-to-buffer Date: Thu, 04 Dec 2008 10:44:12 +0100 Message-ID: <87fxl446mr.fsf@escher.local.home> Reply-To: Stephen Berman , 1488@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1228404274 28676 80.91.229.12 (4 Dec 2008 15:24:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Dec 2008 15:24:34 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 04 16:25:38 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L8G5C-000794-10 for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Dec 2008 16:25:38 +0100 Original-Received: from localhost ([127.0.0.1]:55962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8G41-0000Iq-6J for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Dec 2008 10:24:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L8Aqg-0005Tr-B1 for bug-gnu-emacs@gnu.org; Thu, 04 Dec 2008 04:50:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L8Aqf-0005TT-4d for bug-gnu-emacs@gnu.org; Thu, 04 Dec 2008 04:50:17 -0500 Original-Received: from [199.232.76.173] (port=49870 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8Aqe-0005TC-Re for bug-gnu-emacs@gnu.org; Thu, 04 Dec 2008 04:50:16 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:57203) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L8Aqe-0004rn-7j for bug-gnu-emacs@gnu.org; Thu, 04 Dec 2008 04:50:16 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mB49oD13015629; Thu, 4 Dec 2008 01:50:13 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id mB49o3Hw014927; Thu, 4 Dec 2008 01:50:03 -0800 X-Loop: don@donarmstrong.com Resent-From: Stephen Berman Original-Sender: steve@escher.local.home Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 04 Dec 2008 09:50:02 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1488 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.122838386313577 (code B ref -1); Thu, 04 Dec 2008 09:50:02 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 4 Dec 2008 09:44:23 +0000 Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mB49iJM7013570 for ; Thu, 4 Dec 2008 01:44:21 -0800 Original-Received: from mail.gnu.org ([199.232.76.166]:58084 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1L8AkQ-0000TD-VK for emacs-pretest-bug@gnu.org; Thu, 04 Dec 2008 04:43:51 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1L8Akq-0004JT-Fz for emacs-pretest-bug@gnu.org; Thu, 04 Dec 2008 04:44:18 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]:54300) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1L8Akp-0004JA-MU for emacs-pretest-bug@gnu.org; Thu, 04 Dec 2008 04:44:16 -0500 Original-Received: (qmail invoked by alias); 04 Dec 2008 09:44:13 -0000 Original-Received: from i59F558DC.versanet.de (EHLO escher.local.home) [89.245.88.220] by mail.gmx.net (mp025) with SMTP; 04 Dec 2008 10:44:13 +0100 X-Authenticated: #20778731 X-Provags-ID: V01U2FsdGVkX1/NGFNr8N7NDL9WOtlKqby9n1JW8TEtQU27dZYN89 G05ZVNVvcCRZ95 Original-Received: by escher.local.home (Postfix, from userid 1000) id B140B7FF56; Thu, 4 Dec 2008 10:44:12 +0100 (CET) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.54,0.78 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Thu, 04 Dec 2008 04:50:17 -0500 X-Mailman-Approved-At: Thu, 04 Dec 2008 10:24:20 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:22940 gmane.emacs.pretest.bugs:23459 Archived-At: --=-=-= In GNU Emacs 23.0.60.21 (i686-pc-linux-gnu, GTK+ Version 2.12.9) of 2008-12-03 on escher 1. emacs -Q 2. Eval this: (define-minor-mode my-mm () "My minor mode." :global t (if my-mm (setq default-header-line-format '(:eval (propertize "test" 'face '(:overline t)))) (setq default-header-line-format nil))) 3. Enable my-mm. 4. C-x d foo (where `foo' is some directory with at least three files, e.g. emacs/lisp). 5. Mark three files in foo. 6. Type `C' ==> The popped up buffer *Marked Files* shows only two of the three marked files. Likewise if the value of the 'face property in my-mm has a non-nil :box attribute. In contrast, if the value of the 'face property is '(:underline t) (but not '(:underline t :overline t)), then in step 6 all three marked files are shown, though with no room to spare. I guess the basic problem here is that Emacs calculates window-height in integral equally sized line numbers. But less fundamentally and more directly, this problem arises, AFAICT, because dired-pop-to-buffer's shrink-to-fit code fails to account for header lines. To fix this it would suffice to add this sexp above the last sexp in dired-pop-to-buffer: (with-current-buffer buf (and header-line-format (progn (select-window w2) (enlarge-window 1)))) However, unless I'm missing something, fit-window-to-buffer does what dired-pop-to-buffer's shrink-to-fit code does, and moreover also handles header lines. From perusing the change logs, I found several instances where fit-window-to-buffer replaces library-specific code, and this appears to be another candidate (dired-pop-to-buffer was introduced many years before fit-window-to-buffer), in addition to fixing the above bug. I'm not able to fix the display code to let window-height return fractional line numbers, so I propose the following patch: --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Description: dired-pop-to-buffer patch *** emacs/lisp/dired.el.~1.414.~ 2008-12-03 10:17:51.000000000 +0100 --- emacs/lisp/dired.el 2008-12-04 10:11:05.000000000 +0100 *************** *** 2678,2721 **** (defun dired-pop-to-buffer (buf) ;; Pop up buffer BUF. ;; If dired-shrink-to-fit is t, make its window fit its contents. ! (if (not dired-shrink-to-fit) ! (pop-to-buffer (get-buffer-create buf)) ! ;; let window shrink to fit: ! (let ((window (selected-window)) ! target-lines w2) ! (cond ;; if split-height-threshold is enabled, use the largest window ! ((and (> (window-height (setq w2 (get-largest-window))) ! split-height-threshold) ! (window-full-width-p w2)) ! (setq window w2)) ! ;; if the least-recently-used window is big enough, use it ! ((and (> (window-height (setq w2 (get-lru-window))) ! (* 2 window-min-height)) ! (window-full-width-p w2)) ! (setq window w2))) ! (save-excursion ! (set-buffer buf) ! (goto-char (point-max)) ! (skip-chars-backward "\n\r\t ") ! (setq target-lines (count-lines (point-min) (point))) ! ;; Don't forget to count the last line. ! (if (not (bolp)) ! (setq target-lines (1+ target-lines)))) ! (if (<= (window-height window) (* 2 window-min-height)) ! ;; At this point, every window on the frame is too small to split. ! (setq w2 (display-buffer buf)) ! (setq w2 (split-window window ! (max window-min-height ! (- (window-height window) ! (1+ (max window-min-height target-lines))))))) ! (set-window-buffer w2 buf) ! (if (< (1- (window-height w2)) target-lines) ! (progn ! (select-window w2) ! (enlarge-window (- target-lines (1- (window-height w2)))))) ! (set-window-start w2 1) ! ))) (defcustom dired-no-confirm nil "A list of symbols for commands Dired should not confirm. --- 2678,2687 ---- (defun dired-pop-to-buffer (buf) ;; Pop up buffer BUF. + (pop-to-buffer (get-buffer-create buf)) ;; If dired-shrink-to-fit is t, make its window fit its contents. ! (when dired-shrink-to-fit ! (fit-window-to-buffer (get-buffer-window buf)))) (defcustom dired-no-confirm nil "A list of symbols for commands Dired should not confirm. --=-=-= (Note that if the frame is shrunk so that not all marked file names fit in the *Marked Files* window, then without an oversized header line as is my-mm, dired-pop-to-buffer fails with the error "Attempt to delete minibuffer or sole ordinary window"; whereas with an oversized header line, this error is raised only if not even one file name can be shown. But I see this difference in behavior whether or not the above patch is applied.) Steve Berman --=-=-=--