Subject: Re: bug#77118: 31.0.50; help-key-binding face in help buffer

From: Eli Zaretskii <[email-masked]>
Date: Sat, 12 Apr 2025 10:49:01 +0300

> From: Stephen Berman <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked],
>   [email-masked],  [email-masked]
> Date: Fri, 11 Apr 2025 14:50:57 +0200
> 
> >> diff --git a/lisp/help.el b/lisp/help.el
> >> index b0c003ed16a..c7419b0d0ad 100644
> >> --- a/lisp/help.el
> >> +++ b/lisp/help.el
> >> @@ -2190,8 +2190,11 @@ help-form-show
> >>    "Display the output of a non-nil `help-form'."
> >>    (let ((msg (eval help-form t)))
> >>      (if (stringp msg)
> >> -	(with-output-to-temp-buffer " *Char Help*"
> >> -	  (princ msg)))))
> >> +	(let ((bufname " *Char Help*"))
> >> +          (with-output-to-temp-buffer bufname)
> >> +          (with-current-buffer bufname
> >> +            (let (buffer-read-only)
> >> +              (insert msg)))))))
> >>
> >>  (defun help--append-keystrokes-help (str)
> >>    (let* ((keys (this-single-command-keys))
> >
> > Yes, if this does the job, it's much simpler and safer, IMO.
> 
> Ok.
> 
> > But let's see if anyone else has comments.
> 
> Sure.
> 
> > P.S. Why do we still need with-output-to-temp-buffer, if we just doing
> > the 'insert' part inside the body?
> 
> It's with-output-to-temp-buffer that displays the buffer and insures
> that it's content is up-to-date and also that the buffer is in Help mode
> (the latter is done, IIUC, in the C code via
> read_char_help_form_unwind).  We can avoid with-output-to-temp-buffer
> here with the following patch:

No, let's go with the safe patch above.  I agree with Martin that this
stuff is extremely fragile and should be taken with extra care.

So I think in the above form, this is good for the emacs-30 branch.

Thanks.