-(defun help-window-setup-finish (window &optional reuse keep-frame)
- "Finish setting up help window WINDOW.
-Select WINDOW according to the value of `help-window-select'.
-Display message telling how to scroll and eventually quit WINDOW.
-
-Optional argument REUSE non-nil means WINDOW has been reused by
-`display-buffer'. Optional argument KEEP-FRAME non-nil means
-that quitting should not delete WINDOW's frame."
- (let ((number-of-windows
- (length (window-list (window-frame window) 'no-mini window))))
- (cond
- ((eq window (selected-window))
- ;; The help window is the selected window, probably the
- ;; `pop-up-windows' nil case.
- (help-window-display-message
- (if reuse
- "Type \"q\" to restore this window"
- ;; This should not be taken.
- "Type \"q\" to quit") window))
- ((= number-of-windows 1)
- ;; The help window is alone on a frame and not the selected
- ;; window, could be the `pop-up-frames' t case.
- (help-window-display-message
- (cond
- (keep-frame "Type \"q\" to delete this window")
- (reuse "Type \"q\" to restore this window")
- (view-remove-frame-by-deleting "Type \"q\" to delete this frame")
- (t "Type \"q\" to iconify this frame"))
- window))
- ((and (= number-of-windows 2)
- (eq (window-frame window) (window-frame (selected-window))))
- ;; There are two windows on the help window's frame and the other
- ;; window is the selected one.
- (if (memq help-window-select '(nil other))
- ;; Do not select the help window.
- (help-window-display-message
- (if reuse
- ;; Offer `display-buffer' for consistency with
- ;; `help-print-return-message'. This is hardly TRT when
- ;; the other window and the selected window display the
- ;; same buffer but has been handled this way ever since.
- "Type \\[display-buffer] RET to restore the other window"
- ;; The classic "two windows" configuration.
- "Type \\[delete-other-windows] to delete the help window")
- window t)
- ;; Select help window and tell how to quit.
- (select-window window)
- (help-window-display-message
- (if reuse
- "Type \"q\" to restore this window"
- "Type \"q\" to delete this window") window)))
- (help-window-select
- ;; Issuing a message with 3 or more windows on the same frame
- ;; without selecting the help window doesn't make any sense.
- (select-window window)
- (help-window-display-message
- (if reuse
- "Type \"q\" to restore this window"
- "Type \"q\" to delete this window") window)))))
-
-(defun help-window-setup (list-of-frames list-of-window-tuples)
- "Set up help window.
-LIST-OF-FRAMES and LIST-OF-WINDOW-TUPLES are the lists of frames
-and window quadruples built by `with-help-window'. The help
-window itself is specified by the variable `help-window'."
- (let* ((help-buffer (window-buffer help-window))
- ;; `help-buffer' now denotes the help window's buffer.
- (view-entry
- (assq help-window
- (buffer-local-value 'view-return-to-alist help-buffer)))
- (help-entry (assq help-window list-of-window-tuples)))
-
- ;; Handle `help-window-point-marker'.
- (when (eq (marker-buffer help-window-point-marker) help-buffer)
- (set-window-point help-window help-window-point-marker)
- ;; Reset `help-window-point-marker'.
- (set-marker help-window-point-marker nil))
+(defun help-window-setup (help-window)
+ "Set up help window for `with-help-window'.
+HELP-WINDOW is the window used for displaying the help buffer."
+ (let* ((help-buffer (when (window-live-p help-window)
+ (window-buffer help-window)))
+ (help-setup (when (window-live-p help-window)
+ (car (window-parameter help-window 'quit-restore)))))
+ (when help-buffer
+ ;; Handle `help-window-point-marker'.
+ (when (eq (marker-buffer help-window-point-marker) help-buffer)
+ (set-window-point help-window help-window-point-marker)
+ ;; Reset `help-window-point-marker'.
+ (set-marker help-window-point-marker nil))