Subject: Re: bug#68236: [PATCH] help.el: allow help-quick to use local commands/quick-sections

From: JD Smith <[email-masked]>
Date: Thu, 4 Jan 2024 20:28:27 -0500

> On Jan 4, 2024, at 8:57 AM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: JD Smith <[email-masked]>
>> Date: Thu, 4 Jan 2024 08:45:50 -0500
>> Cc: [email-masked]
>> 
>> On Jan 4, 2024, at 2:39 AM, Eli Zaretskii <[email-masked]> wrote:
>> 
>> Please describe in more detail how would people use this for their
>> personal "quick help", because I don't think I understand well enough
>> what you have in mind.
>> 
>> For example, an org user may
>> 
>> (add-to-list 'help-quick-sections
>>             '("Org"
>>      (org-ctrl-c-star . "Compute table/change heading ")
>>      (org-ctrl-c-ret . "Table hline/insert heading")))
>> 
>> so that from org-buffers, C-h C-q adds a new section:
>> 
>> Org                                  
>> C-c *   Compute table/change heading 
>> C-c RET Table hline/insert heading   
>> 
>> Most likely users willing to customize `help-quick-sections’ would remove existing sections with
>> commands they know well.  
>> 
>> In any case, such a change will need suitable changes for
>> documentation.
>> 
>> Do you mean documentation for the `help-quick-sections' variable?  How about turning this into a
>> defcustom?  This would allow more advanced users to fully customize what “quick help” they want.
> 
> If we are going to expose help-quick-sections as a defcustom, then I
> don't understand why we need to change the code at all.  Is the idea
> that sections will depend on the current buffer?  If so, then we just
> need to add an element to the list members which will store the
> major-mode for which the member is relevant.
> 
> Or what am I missing?

Right now the code does

  (with-current-buffer (get-buffer-create "*Quick Help*")

right away, then checks `where-is-internal' for each listed command in `help-quick-sections'.  So only global bindings (and bindings available in help-mode) are accessible for display.  My patch simply delays switching to *Quick Help* buffer, so that binding information can be gathered from the local buffer from which quick help was summoned.  Note that help-quick omits any bindings that are nil, as well as any empty sections.  So adding sections to the defcustom that do not apply (=have no bindings) in some buffer is not a problem.