+ (let ((first-message
+ (cond ((or (member (buffer-name standard-output)
+ special-display-buffer-names)
+ (assoc (buffer-name standard-output)
+ special-display-buffer-names)
+ (let (found
+ (tail special-display-regexps)
+ (name (buffer-name standard-output)))
+ (while (and tail (not found))
+ (if (or (and (consp (car tail))
+ (string-match (car (car tail)) name))
+ (and (stringp (car tail))
+ (string-match (car tail) name)))
+ (setq found t))
+ (setq tail (cdr tail)))
+ found))
+ ;; If the help output buffer is a special display buffer,
+ ;; don't say anything about how to get rid of it.
+ ;; First of all, the user will do that with the window
+ ;; manager, not with Emacs.
+ ;; Secondly, the buffer has not been displayed yet,
+ ;; so we don't know whether its frame will be selected.
+ ;; Even the message about scrolling the help
+ ;; might be wrong, but it seems worth showing it anyway.
+ nil)
+ ((not (one-window-p t))
+ "Type \\[switch-to-buffer-other-window] RET to restore the other window.")
+ (pop-up-windows
+ "Type \\[delete-other-windows] to remove help window.")
+ (t
+ "Type \\[switch-to-buffer] RET to remove help window."))))
+ (funcall (or function 'message)
+ (concat
+ (if first-message
+ (substitute-command-keys first-message)
+ "")
+ (if first-message " " "")
+ ;; If the help buffer will go in a separate frame,
+ ;; it's no use mentioning a command to scroll, so don't.
+ (if (or (member (buffer-name standard-output)
+ special-display-buffer-names)
+ (assoc (buffer-name standard-output)
+ special-display-buffer-names)
+ (memq t (mapcar '(lambda (elt)
+ (if (consp elt)
+ (setq elt (car elt)))
+ (string-match elt (buffer-name standard-output)))
+ special-display-regexps)))
+ nil
+ (if (or (member (buffer-name standard-output)
+ same-window-buffer-names)
+ (assoc (buffer-name standard-output)
+ same-window-buffer-names)
+ (memq t (mapcar '(lambda (elt)
+ (if (consp elt)
+ (setq elt (car elt)))
+ (string-match elt (buffer-name standard-output)))
+ same-window-regexps)))
+ ;; Say how to scroll this window.
+ (substitute-command-keys
+ "\\[scroll-up] to scroll the help.")
+ ;; Say how to scroll some other window.
+ (substitute-command-keys
+ "\\[scroll-other-window] to scroll the help."))))))))