Subject: Re: bug#19012: 25.0.50; `help-window-select'

From: martin rudalics <[email-masked]>
Date: Tue, 11 Nov 2014 09:29:53 +0100

> This is the relevant code:
 >
 > (add-to-list
 >   'special-display-buffer-names
 >   (list "*Help*" '1on1-display-*Help*-frame
 >         (list (cons 'background-color 1on1-help-frame-background)
 >               (cons 'mouse-color 1on1-help-frame-mouse+cursor-color)
 >               (cons 'cursor-color 1on1-help-frame-mouse+cursor-color)
 >               '(height . 40))))
 >
 > (defun 1on1-display-*Help*-frame (buf &optional args)
 >    "Display *Help* buffer in its own frame.
 > `special-display-function' is used to do the actual displaying.
 > BUF and ARGS are the arguments to `special-display-function'."
 >    (let ((old-ptr-shape  (and (boundp 'x-pointer-shape) x-pointer-shape))
 >          return-window)
 >      (when (boundp 'x-pointer-xterm) (setq x-pointer-shape  x-pointer-xterm))
 >      (setq return-window
 >            (select-window (funcall special-display-function buf args)))
 >      (raise-frame)
 >      (setq x-pointer-shape  old-ptr-shape)
 >      return-window))
 >
 > Does that mean that `with-help-window' is not involved?

Who creates the *Help* buffer and who calls `display-buffer' in the case
at hand?

 > Maybe so,
 > but it's not obvious to me.  How is a user supposed to know whether
 > this option applies, i.e., whether "the help window was created by
 > `with-help-window'?

By trial and error, I suppose.  I wrote `with-help-window' seven years
ago because there were many complaints about the previous behavior.  And
I hardly had any complaints since that.  `with-help-window' has to cater
for people who don't know what an option is or how it can be
customized.  Still, those people want to get help via C-h and get rid of
that help afterwards.  When such people later find that the help window
gets selected in some unintuitive way they can tune the behavior using
this option.

 > And why shouldn't such an option apply in general for the help window?
 > Why must it depend on how the window is created?

Because it relies on things set up correctly at the time the window is
created.  Most of the work I put into `with-help-window' was about
storing information that would allow quitting to return to the previous
state as smoothly as possible.

 > Maybe so, but it's not very clear, IMO.  The vacuous case should be
 > mentioned explicitly, I think, and not depend for its understanding on
 > finessing the logic.  Just say, for value `other', that "if the help
 > window is alone in its frame then it is selected".

I'll do that.

 > With the scenario I described (*Help* is alone in its frame, in a
 > dedicated window, and the *Help* frame exists prior to calling the
 > help command) and with a value of `other' or `t', the *Help* window
 > is *not* selected.
 >
 > With your interpretation, the "unless" condition is false, so the
 > *Help* window should be selected

Indeed.  It would be a bug if it didn't get selected.

 > (except that perhaps
 > `with-help-window' is not involved - dunno about that).

martin