GNU bug report logs - #1488
23.0.60; dired-pop-to-buffer: use fit-window-to-buffer

Previous Next

Package: emacs;

Reported by: Stephen Berman <Stephen.Berman <at> rub.de>

Date: Thu, 4 Dec 2008 09:50:02 UTC

Severity: normal

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (Emacs bug Tracking System)
To: martin rudalics <rudalics <at> gmx.at>
Subject: bug#1488: marked as done (23.0.60; dired-pop-to-buffer: use 
 fit-window-to-buffer)
[Message part 1 (text/plain, inline)]
Your message dated Thu, 11 Dec 2008 10:56:56 +0100
with message-id <4940E3E8.8050501 <at> gmx.at>
and subject line Re: bug#1488: 23.0.60; dired-pop-to-buffer: use fit-window-to-buffer
has caused the Emacs bug report #1488,
regarding 23.0.60; dired-pop-to-buffer: use fit-window-to-buffer
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don <at> donarmstrong.com
immediately.)


-- 
1488: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1488
Emacs Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stephen Berman <Stephen.Berman <at> rub.de>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; dired-pop-to-buffer: use fit-window-to-buffer
Date: Thu, 04 Dec 2008 10:44:12 +0100
[Message part 3 (text/plain, inline)]
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:

[Message part 4 (text/x-patch, inline)]
*** 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.
[Message part 5 (text/plain, inline)]
(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
[Message part 6 (message/rfc822, inline)]
From: martin rudalics <rudalics <at> gmx.at>
To: 1488-done <at> debbugs.gnu.org
Subject: Re: bug#1488: 23.0.60; dired-pop-to-buffer: use fit-window-to-buffer
Date: Thu, 11 Dec 2008 10:56:56 +0100
Fixed as

2008-12-11  Stephen Berman <Stephen.Berman <at> rub.de>

	* dired.el (dired-pop-to-buffer): Use fit-window-to-buffer when
	dired-shrink-to-fit is non-nil.  (Bug#1488)

Thanks, martin.



This bug report was last modified 16 years and 166 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.