Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in updated eldoc
From: Alex Branham <[email-masked]>
To: João Távora <[email-masked]>
Cc: "Basil L. Contovounesios" <[email-masked]>, Stefan Monnier <[email-masked]>, [email-masked]
Date: Sun, 28 Mar 2021 12:05:46 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

On Sun 28 Mar 2021 at 15:50, João Távora <[email-masked]> wrote:

> Alex Branham <[email-masked]> writes:
>
>> On Sat 27 Mar 2021 at 12:53, João Távora <[email-masked]> wrote:
>>
>> Thanks! It sounds like the below is what you're suggesting modes do in
>> order to support all the possible eldoc+Emacs versions, let me know if
>> I've misunderstood.
>>
>> (if (not (boundp 'eldoc-documentation-functions))
>>     ;; old eldoc
>>     (add-function :before-until (local 'eldoc-documentation-function)
>>                   #'ess-r-eldoc-function)
>>   ;; new eldoc
>>   (add-hook 'eldoc-documentation-functions #'ess-r-eldoc-function nil t)
>>   ;; new eldoc + Emacs 27.1
>>   (when (and (fboundp 'eldoc-documentation-default) 
>>              (function-equal #'ignore eldoc-documentation-function))
>>     (setq-local eldoc-documentation-function
>> #'eldoc-documentation-default)))
>
> You don't need to be as complex as this:
>
> (if (not (boundp 'eldoc-documentation-strategy))
>     (add-function :before-until (local 'eldoc-documentation-function)
>                    #'ess-r-eldoc-function)
>   (add-hook 'eldoc-documentation-functions #'ess-r-eldoc-function nil t)
>   (when (function-equal #'ignore eldoc-documentation-function)
>         (setq-local eldoc-documentation-function #'eldoc-documentation-default|compose|whatever))))

The fboundp check will avoid a byte compiler warning on Emacs<28.

>> If that's right, it seems like a step backwards, ease-of-setup-wise at
>> least, from the simple
>>
>> (add-function :before-until (local 'eldoc-documentation-function)
>> #'ess-r-eldoc-function)
>
> You can still just that and call it a day.  Just that, because the new
> eldoc in the yet-unreleased Emacs 28 is backward compatible.  I've tried
> to explain this three times already in this exchange.

Thanks. I'd like to support the new way (so users can customize
eldoc-documentation-function) and the old way, which I thought I had
said previously. It seems like the above is the officially blessed way
to do both so I suppose that's what we'll go with.

Thanks again, closing this bug report.