Subject: Re: bug#1806: dired-pop-to-buffer in wrong place

From: martin rudalics <[email-masked]>
Date: Thu, 04 Oct 2012 09:44:53 +0200

> Do you think this is a good formulation:
 >
 > === modified file 'lisp/dired.el'
 > --- lisp/dired.el	2012-09-30 12:11:18 +0000
 > +++ lisp/dired.el	2012-10-03 23:28:07 +0000
 > @@ -248,6 +248,10 @@ (defvar dired-shrink-to-fit t
 >  ;; I see no reason ever to make this nil -- rms.
 >  ;;  (> baud-rate search-slow-speed)
 >    "Non-nil means Dired shrinks the display buffer to fit the marked files.")
 > +(make-obsolete-variable 'dired-shrink-to-fit
 > +			"use the Customization interface to add a new rule
 > +to `display-buffer-alist' where condition regexp is \"Marked Files\",
 > +action argument symbol is `window-height' and its value is nil." "24.3")

I think it's OK.  Though we should decide generally whether we (1) want
an exact match for such buffers (that is, including space and asterisks)
and (2) whether obsoletion strings can be that long (I have not found
any when I searched recently).

 >  (defvar dired-file-version-alist)
 >
 > @@ -2940,6 +2943,7 @@ (defun dired-mark-prompt (arg files)
 >
 >  (defun dired-pop-to-buffer (buf)
 >    "Pop up buffer BUF in a way suitable for Dired."
 > +  (declare (obsolete dired-mark-pop-up "24.3"))
 >    (let ((split-window-preferred-function
 >  	 (lambda (window)
 >  	   (or (and (let ((split-height-threshold 0))
 > @@ -2981,6 +2985,11 @@ (defun dired-mark-pop-up (buffer-or-name
 >  window is not shown if there is just one file, `dired-no-confirm'
 >  is t, or OP-SYMBOL is a member of the list in `dired-no-confirm'.
 >
 > +By default Dired shrinks the display buffer to fit the marked files.
 > +To disable this, use the Customization interface to add a new rule
 > +to `display-buffer-alist' where condition regexp is \"Marked Files\",
 > +action argument symbol is `window-height' and its value is nil.
 > +
 >  FILES is the list of marked files.  It can also be (t FILENAME)
 >  in the case of one marked file, to distinguish that from using
 >  just the current file.

We should add the detailed code somewhere, probably to the Elisp manual.
As an example, I didn't know that using an ACTION argument where the
FUNCTION component is nil would work in the first place.

 > PS: Also I noticed that there are no new actions in the Customization
 > interface for `display-buffer-alist'.  I guess you omitted the action
 > `display-buffer-at-bottom' because it's not yet ready for prime time.
 > But is there a reason to not add `display-buffer-below-selected' to
 > `display-buffer--action-function-custom-type'?

No.  I didn't recall that option any more (although I must have done so
earlier because I added `display-buffer-in-previous-window' to it).

There are further issues.

(1) Document alist entries like `window-height' and `window-width'
somehwere without blowing up the doc-string of `display-buffer'.

(2) Decide whether and how we can use `window-height' and `window-width'
to replace `split-height-threshold' and `split-width-threshold'.  Or
maybe find some other substitute.

(3) Include alist entries to specify a minimum height/width for a window
to reuse (there's a request for such a feature in a bug report).

(4) As soon as we switch to pixel sizes allow to specify all these
options in terms of pixels too.

(5) Handle the delayed evaluation of `fit-window-to-buffer' in
`vc-diff-finish' somehow.  Currently, we can't pass this to
`display-buffer' because we don't know the final size of the buffer when
we call it.  So this means that we have to find out whether
`display-buffer' would have called `fit-window-to-buffer' in the first
place and, if so, call `fit-window-to-buffer' when we know the final
buffer size.  Tedious to do.

(6) Related: Move `display-buffer-mark-dedicated' to the alists.

martin