Subject: bug#17809: 24.4.50; Completions display

From: Juri Linkov <[email-masked]>
Date: Wed, 02 Jul 2014 02:30:17 +0300

forcemerge 17809 12618
thanks

[ I discovered the same bug report from Dani, so merging both. ]

>> Maybe it would be a good thing to add a new action parameter to
>> `display-buffer' that would be like the existing `quit-function'
>> in `with-current-buffer-window', and will call its body between
>> displaying the buffer and applying final actions alists like
>> (window-height . fit-window-to-buffer)
>
> `display-buffer' has no body and hardly ever will get one.

I really see no difference between the already existing
QUIT-FUNCTION and a new possible BODY-FUNCTION.

Currently QUIT-FUNCTION is called this way in
`with-current-buffer-window':

       (if (functionp ,quit-function)
           (funcall ,quit-function ,window ,value)

and BODY-FUNCTION could be called in `window--display-buffer'
with something like:

       (if (functionp (cdr (assq 'body-function alist)))
           (funcall (cdr (assq 'body-function alist)))

Then, for instance, `dired-mark-pop-up' instead of:

        (with-current-buffer-window
         buffer
         (cons 'display-buffer-below-selected
               '((window-height . fit-window-to-buffer)))
         #'(lambda (window _value)
             (with-selected-window window
               (with-current-buffer buffer
                 (let ((inhibit-read-only t))
                   (dired-format-columns-of-files
                    (if (eq (car files) t) (cdr files) files))

will use:

        (with-current-buffer-window
         buffer
         (cons 'display-buffer-below-selected
               '((window-height . fit-window-to-buffer)
                 (body-function .
                  (lambda ()
                    (with-current-buffer buffer
                      (let ((inhibit-read-only t))
                        (dired-format-columns-of-files
                         (if (eq (car files) t) (cdr files) files))

Is there a problem with this approach?