+ (setq user-data (list filebuf dirbuf filewin dirwin))
+ (set-window-buffer (frame-lowest-window frame) butbuf)
+
+ ;; set up completion buffers.
+ (let ((rfcshookfun
+ ;; kludge!
+ ;; #### I really need to flesh out the object
+ ;; hierarchy better to avoid these kludges.
+ ;; (?? I wrote this comment above some time ago,
+ ;; and I don't understand what I'm referring to
+ ;; any more. --ben
+ (lambda ()
+ (mouse-rfn-setup-vars prompt)
+ (when (featurep 'scrollbar)
+ (set-specifier scrollbar-width 0 (current-buffer)))
+ (setq truncate-lines t))))
+
+ (set-buffer filebuf)
+ (add-local-hook 'completion-setup-hook rfcshookfun)
+ (when file-p
+ (set-buffer dirbuf)
+ (add-local-hook 'completion-setup-hook rfcshookfun)))
+
+ ;; set up minibuffer.
+ (add-one-shot-hook
+ 'minibuffer-setup-hook
+ (lambda ()
+ (if (not file-p)
+ (mouse-directory-display-completion-list
+ filewin dir (current-buffer) user-data)
+ (mouse-file-display-completion-list
+ filewin dir (current-buffer) user-data)
+ (mouse-directory-display-completion-list
+ dirwin dir (current-buffer) user-data))
+ (set
+ (make-local-variable
+ 'completion-display-completion-list-function)
+ (lambda (completions)
+ (display-completion-list
+ completions
+ :help-string ""
+ :window-width (window-width filewin)
+ :window-height (window-text-area-height filewin)
+ :completion-string ""
+ :activate-callback
+ 'mouse-read-file-name-activate-callback
+ :user-data user-data)))
+ (mouse-rfn-setup-vars prompt)
+ (save-selected-window
+ ;; kludge to ensure the frame title is correct.
+ ;; the minibuffer leaves the frame title the way
+ ;; it was before (i.e. of the selected window before
+ ;; the dialog box was opened), so to get it correct
+ ;; we have to be tricky.
+ (select-window filewin)
+ (redisplay-frame nil t)
+ ;; #### another kludge. sometimes the focus ends up
+ ;; back in the main window, not the dialog box. it
+ ;; occurs randomly and it's not possible to reliably
+ ;; reproduce. We try to fix it by draining non-user
+ ;; events and then setting the focus back on the frame.
+ (sit-for 0 t)
+ (focus-frame frame))))
+
+ ;; set up button buffer.
+ (set-buffer butbuf)
+ (mouse-rfn-setup-vars prompt)