GNU bug report logs - #47388
27.1; eldoc-documentation-function is ignore in updated eldoc

Previous Next

Package: emacs;

Reported by: Alex Branham <alex.branham <at> gmail.com>

Date: Thu, 25 Mar 2021 14:06:01 UTC

Severity: normal

Found in version 27.1

Done: Alex Branham <alex.branham <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47388 in the body.
You can then email your comments to 47388 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Thu, 25 Mar 2021 14:06:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex Branham <alex.branham <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 25 Mar 2021 14:06:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; eldoc-documentation-function is ignore in updated eldoc
Date: Thu, 25 Mar 2021 10:05:40 -0400
Hello -

Emacs 27.1 ships with eldoc that defines eldoc-documentation-function as
#'ignore. If users install eglot from ELPA, this pulls in an updated
eldoc that attempts to redefine eldoc-documentation-function. However,
the value does not change (since eldoc-documentation-function is already
bound, defcustom does not update it when called in
eldoc--documentation-strategy-defcustom) so the value is still ignore,
meaning users get:

    There is no ElDoc support in this buffer

since eldoc-documentation-function is #'ignore, regardless of the value
of eldoc-documentation-functions.

Here's the bug report we received with the original issue:
https://github.com/emacs-ess/ESS/issues/1130

Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Fri, 26 Mar 2021 18:29:02 GMT) Full text and rfc822 format available.

Message #8 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: João Távora <joaotavora <at> gmail.com>,
 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Fri, 26 Mar 2021 18:27:53 +0000
Alex Branham <alex.branham <at> gmail.com> writes:

> Emacs 27.1 ships with eldoc that defines eldoc-documentation-function as
> #'ignore. If users install eglot from ELPA, this pulls in an updated
> eldoc that attempts to redefine eldoc-documentation-function. However,
> the value does not change (since eldoc-documentation-function is already
> bound, defcustom does not update it when called in
> eldoc--documentation-strategy-defcustom) so the value is still ignore,
> meaning users get:
>
>     There is no ElDoc support in this buffer
>
> since eldoc-documentation-function is #'ignore, regardless of the value
> of eldoc-documentation-functions.
>
> Here's the bug report we received with the original issue:
> https://github.com/emacs-ess/ESS/issues/1130

Thanks, CCing João.

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Fri, 26 Mar 2021 18:51:01 GMT) Full text and rfc822 format available.

Message #11 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Fri, 26 Mar 2021 18:50:10 +0000
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> Alex Branham <alex.branham <at> gmail.com> writes:
>
>> Emacs 27.1 ships with eldoc that defines eldoc-documentation-function as
>> #'ignore. If users install eglot from ELPA, this pulls in an updated
>> eldoc that attempts to redefine eldoc-documentation-function. However,
>> the value does not change (since eldoc-documentation-function is already
>> bound, defcustom does not update it when called in
>> eldoc--documentation-strategy-defcustom) so the value is still ignore,
>> meaning users get:
>>
>>     There is no ElDoc support in this buffer
>>
>> since eldoc-documentation-function is #'ignore, regardless of the value
>> of eldoc-documentation-functions.
>>
>> Here's the bug report we received with the original issue:
>> https://github.com/emacs-ess/ESS/issues/1130
>
> Thanks, CCing João.

Thanks Basil, Alex,

Alex, exactly under what circunstances do you see that "There is no
ElDoc support in this buffer"?  In what buffer, doing what?  I
appreciate that you have investigated the implementation, but I need to
be able to understand -- and potentially reproduce -- the problem
exactly as it happened to you, so please provide as clear a recipe as
possible, perhaps starting with "downloaded Emacs 27.1, then cleared my
ELPA directory, ..., installed Eglot from xyz, ..., ".

Meanwhile (but not excluding the earlier valuable exercise), can you
show the output of:

  C-h v eldoc-documentation-function RET
  C-h v eldoc-documentation-strategy RET

?

Thanks again,
João






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Fri, 26 Mar 2021 19:10:01 GMT) Full text and rfc822 format available.

Message #14 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Fri, 26 Mar 2021 15:08:59 -0400
On Fri 26 Mar 2021 at 18:50, João Távora <joaotavora <at> gmail.com> wrote:

> Alex, exactly under what circunstances do you see that "There is no
> ElDoc support in this buffer"?  In what buffer, doing what?  I
> appreciate that you have investigated the implementation, but I need to
> be able to understand -- and potentially reproduce -- the problem
> exactly as it happened to you, so please provide as clear a recipe as
> possible, perhaps starting with "downloaded Emacs 27.1, then cleared my
> ELPA directory, ..., installed Eglot from xyz, ..., ".

Sure thing (though note I'm not the person who originally ran into the
bug, just was able to reproduce). From a clean install of 27.1 (no init
file, no packages), you should be able to reproduce by:

1. Add MELPA to package-archives
2. Install ESS
3. Update eldoc (potentially by installing eglot)
4. Restart Emacs
5. (require 'eglot)
6. Open an R file (eg ~/test.R)
7. At this point, eldoc-documentation-function will be #'ignore so eg
   M-x eldoc-mode will show "There is no ElDoc support in this buffer".

That's because ESS sets up eldoc in R buffers like so:

  (if (boundp 'eldoc-documentation-functions)
      (add-hook 'eldoc-documentation-functions #'ess-r-eldoc-function nil t)
    (add-function :before-until (local 'eldoc-documentation-function)
                  #'ess-r-eldoc-function))

so we don't touch eldoc-documentation-function in newer eldoc versions
where it is supposed to be a user-facing customization.

> Meanwhile (but not excluding the earlier valuable exercise), can you
> show the output of:
>
>   C-h v eldoc-documentation-function RET
>   C-h v eldoc-documentation-strategy RET

Unfortunately I can't at the moment but from memory
eldoc-documentation-strategy was an obsolete alias for
eldoc-documentation-function and the value was the function ignore.

Hope that helps.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Fri, 26 Mar 2021 19:58:02 GMT) Full text and rfc822 format available.

Message #17 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Fri, 26 Mar 2021 19:57:12 +0000
Alex Branham <alex.branham <at> gmail.com> writes:

> On Fri 26 Mar 2021 at 18:50, João Távora <joaotavora <at> gmail.com> wrote:
>
>> Alex, exactly under what circunstances do you see that "There is no
>> ElDoc support in this buffer"?  In what buffer, doing what?  I
>> appreciate that you have investigated the implementation, but I need to
>> be able to understand -- and potentially reproduce -- the problem

> 7. At this point, eldoc-documentation-function will be #'ignore so eg
                                                       ^^^^^^^^ 
So this is where I'm completely baffled.  You say this ||||||||

But earlier you said, accurately, in fact it was your first sentence, that:

>>>> Emacs 27.1 ships with eldoc that defines
>>>> eldoc-documentation-function as #'ignore.

So if it was #'ignore and still is #'ignore what exactly is the
difference that (require 'eldoc) or (require 'eglot) is introducing??

João




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Fri, 26 Mar 2021 20:01:02 GMT) Full text and rfc822 format available.

Message #20 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: QuietApe <quietape <at> lunarhaven.net>
To: 47388 <at> debbugs.gnu.org
Date: Fri, 26 Mar 2021 20:52:30 +0100
[Message part 1 (text/plain, inline)]
Hello,

I'm the user that run into this bug, the exact output of the command are:

> C-h v eldoc-documentation-function RET

eldoc-documentation-function is a variable defined in ‘eldoc.el’.
Its value is ‘ignore’
Original value was ‘eldoc-documentation-default’
This variable has an alias: ‘eldoc-documentation-strategy’.

> C-h v eldoc-documentation-strategy RET

eldoc-documentation-strategy is a variable defined in ‘eldoc.el’.
Its value is ‘ignore’
This variable is an alias for ‘eldoc-documentation-function’.
This variable is obsolete since eldoc-1.1.0; use 
‘eldoc-documentation-function’ instead.

If it helps to add information to what Alex said.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Fri, 26 Mar 2021 20:25:01 GMT) Full text and rfc822 format available.

Message #23 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Fri, 26 Mar 2021 16:23:50 -0400
[Message part 1 (text/plain, inline)]
Because then we modify el-doc-functions because of the newer version of
eldoc loaded.

But the ignore value of el-doc-function prevents eldoc from working

Hopefully that helps, sorry for the brevity am on phone

On Fri, Mar 26, 2021, 3:57 PM João Távora <joaotavora <at> gmail.com> wrote:

> Alex Branham <alex.branham <at> gmail.com> writes:
>
> > On Fri 26 Mar 2021 at 18:50, João Távora <joaotavora <at> gmail.com> wrote:
> >
> >> Alex, exactly under what circunstances do you see that "There is no
> >> ElDoc support in this buffer"?  In what buffer, doing what?  I
> >> appreciate that you have investigated the implementation, but I need to
> >> be able to understand -- and potentially reproduce -- the problem
>
> > 7. At this point, eldoc-documentation-function will be #'ignore so eg
>                                                        ^^^^^^^^
> So this is where I'm completely baffled.  You say this ||||||||
>
> But earlier you said, accurately, in fact it was your first sentence, that:
>
> >>>> Emacs 27.1 ships with eldoc that defines
> >>>> eldoc-documentation-function as #'ignore.
>
> So if it was #'ignore and still is #'ignore what exactly is the
> difference that (require 'eldoc) or (require 'eglot) is introducing??
>
> João
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Fri, 26 Mar 2021 20:35:02 GMT) Full text and rfc822 format available.

Message #26 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Fri, 26 Mar 2021 20:34:16 +0000
[Message part 1 (text/plain, inline)]
On Fri, Mar 26, 2021 at 8:24 PM Alex Branham <alex.branham <at> gmail.com> wrote:

> Because then we modify el-doc-functions because of the newer version of
> eldoc loaded.
>
> But the ignore value of el-doc-function prevents eldoc from working
>
> Hopefully that helps, sorry for the brevity am on phone
>

Ah, I get it, so ess-mode does something different.  Then
maybe it should also set eldoc-documentation-strategy
to something sensible.  Eldoc-documentation-strategy is
just the new name of eldoc-documentation-function.
If you find an `ignore` there, you're safe to change it
, buffer-locally, as you did before.  Maybe you should
even do it even if you _don't_ find an ignore there.
The fact that it's now defcustom doesn't change much
in my opinion, I don't see defcustom's as off-limits to major/minor
modes, as long as the user is still given override power
in the mode hooks.

Alternatively, ess-mode should just use the old interface.
It's still available and functional.

But I think you should select a strategy that suits `ess-mode`'s
functions.

Hope this helps,
João
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sat, 27 Mar 2021 12:07:02 GMT) Full text and rfc822 format available.

Message #29 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sat, 27 Mar 2021 08:06:45 -0400
On Fri 26 Mar 2021 at 20:34, João Távora <joaotavora <at> gmail.com> wrote:

> Ah, I get it, so ess-mode does something different.

I'm not sure I understand - different from what?

> Then maybe it should also set eldoc-documentation-strategy to
> something sensible. Eldoc-documentation-strategy is just the new name
> of eldoc-documentation-function. If you find an `ignore` there, you're
> safe to change it , buffer-locally, as you did before. Maybe you
> should even do it even if you _don't_ find an ignore there. The fact
> that it's now defcustom doesn't change much in my opinion, I don't see
> defcustom's as off-limits to major/minor modes, as long as the user is
> still given override power in the mode hooks.
>
> Alternatively, ess-mode should just use the old interface.
> It's still available and functional.
>
> But I think you should select a strategy that suits `ess-mode`'s
> functions.

So the recommended strategy to support 27.1+old eldoc, 27.1+new eldoc,
and 28.0+new eldoc is something like the below?

(if (function-equal #'ignore eldoc-documentation-function)
    (add-hook 'eldoc-documentation-functions #'ess-r-eldoc-function nil t)
  (add-function :before-until (local 'eldoc-documentation-function)
                #'ess-r-eldoc-function))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sat, 27 Mar 2021 12:54:02 GMT) Full text and rfc822 format available.

Message #32 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sat, 27 Mar 2021 12:53:13 +0000
[Message part 1 (text/plain, inline)]
On Sat, Mar 27, 2021 at 12:06 PM Alex Branham <alex.branham <at> gmail.com>
wrote:

> On Fri 26 Mar 2021 at 20:34, João Távora <joaotavora <at> gmail.com> wrote:
>
> > Ah, I get it, so ess-mode does something different.
>
> I'm not sure I understand - different from what?
>

It does different things depending on the situation it thinks
it finds itself in.

(if (function-equal #'ignore eldoc-documentation-function)
>     (add-hook 'eldoc-documentation-functions #'ess-r-eldoc-function nil t)
>   (add-function :before-until (local 'eldoc-documentation-function)
>                 #'ess-r-eldoc-function))
>

I'm not sure you're improving much here.  My idea is that,
if you find eldoc-documentation-functions (plural) to be bound you
may need to check that eldoc-documentation-strategy (or
eldoc-documentation-function (singular)) ISN'T #ignore and
buffer-locally adjust it accordingly to something of your preference
or your users' preference.

Alternatively, you can just keep using the old technique which is a lot
of parts of Emacs do (like elisp-mode in Emacs 27.1, for example), i.e.
use the else branch in your if, and only that.  You don't seem to be using a
ny of the new ElDoc features like multiple documentation functions anyway.
That should also work for your Eglot-less rss-mode.

When using Eglot-ified rss-mode Eglot will do the right thing regardless
of the approach you take above.

All this said, I think this issue should be kept open nonetheless. If indeed
the new package's defcustom could clobber the global value of
eldoc-documentation-function if it finds it to be #'ignore I think it
should
be fine.

CC-ing Stefan Monnier for an opinion on this last part.

João Távora
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 11:24:02 GMT) Full text and rfc822 format available.

Message #35 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 07:23:47 -0400
On Sat 27 Mar 2021 at 12:53, João Távora <joaotavora <at> gmail.com> wrote:

> I'm not sure you're improving much here.  My idea is that,
> if you find eldoc-documentation-functions (plural) to be bound you
> may need to check that eldoc-documentation-strategy (or
> eldoc-documentation-function (singular)) ISN'T #ignore and
> buffer-locally adjust it accordingly to something of your preference
> or your users' preference.

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)))

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)

that we did before new eldoc. But maybe it's necessary, I haven't really
played around with the new eldoc features at all.

Thanks again!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 14:51:01 GMT) Full text and rfc822 format available.

Message #38 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 15:50:38 +0100
Alex Branham <alex.branham <at> gmail.com> writes:

> On Sat 27 Mar 2021 at 12:53, João Távora <joaotavora <at> gmail.com> wrote:
>
>> I'm not sure you're improving much here.  My idea is that,
>> if you find eldoc-documentation-functions (plural) to be bound you
>> may need to check that eldoc-documentation-strategy (or
>> eldoc-documentation-function (singular)) ISN'T #ignore and
>> buffer-locally adjust it accordingly to something of your preference
>> or your users' preference.
>
> 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))))

> 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.

João





Reply sent to Alex Branham <alex.branham <at> gmail.com>:
You have taken responsibility. (Sun, 28 Mar 2021 16:06:01 GMT) Full text and rfc822 format available.

Notification sent to Alex Branham <alex.branham <at> gmail.com>:
bug acknowledged by developer. (Sun, 28 Mar 2021 16:06:02 GMT) Full text and rfc822 format available.

Message #43 received at 47388-done <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 47388-done <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 12:05:46 -0400
On Sun 28 Mar 2021 at 15:50, João Távora <joaotavora <at> gmail.com> wrote:

> Alex Branham <alex.branham <at> gmail.com> writes:
>
>> On Sat 27 Mar 2021 at 12:53, João Távora <joaotavora <at> gmail.com> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 16:38:01 GMT) Full text and rfc822 format available.

Message #46 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 12:37:47 -0400
>   (when (function-equal #'ignore eldoc-documentation-function)
>         (setq-local eldoc-documentation-function #'eldoc-documentation-default|compose|whatever))))

BTW, using code like the one above is tolerable, usually for historical
reasons, but new APIs should aim not to need such things: comparing
functions is fundamentally always a hack.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 18:46:02 GMT) Full text and rfc822 format available.

Message #49 received at 47388-done <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 47388-done <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 19:45:47 +0100
Alex Branham <alex.branham <at> gmail.com> writes:

>>> 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.

No idea what the "above" is, let me just summarize the cases:

(1) You have Emacs <= 27.1 and no new eldoc.el package
(2) You have Emacs <= 27.1 and a new eldoc.el package
(3) You have Emacs >= 28

The typical (fboundp 'eldoc-documentation-functions) check works great
for cases 1 and 3: you support the new and the old way.  Now, sometime
in 2020 I introduced the possibility of delivering new Eldoc features to
released versions, via the Eldoc ELPA "core" package.  That gave rise to
case 2: it's offering a new possiblity to support new Eldoc features
early, it doesn't remove any possibilities.

So:

a) If you want to support the new Eldoc features in cases 2 and 3, you
   have to use the more complex snippet (with or without the
   byte-compiler warning, you decide if it bothers you)

b) If, on the other hand, you just want to support 1 and 3, just use a
   check on emacs-major-version, instead of the fboundp check.

c) If you're confident that your users won't be missing the new eldoc.el
   features in rss-mode specifically (there's a good chance they won't
   since it's presumably what they're used to in rss-mode), just use the
   simple :before-until snippet.  And if these users do install something
   like Eglot, it will take care to do the right thing.

d) If you want to only support 2 and 3, and join the wave of the future,
   you can: Just make the eldoc.el ELPA package a dependency of the
   rss-mode, much like Eglot.

So I think you have lots of options here.

João






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 18:57:02 GMT) Full text and rfc822 format available.

Message #52 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 19:56:13 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>   (when (function-equal #'ignore eldoc-documentation-function)
>>         (setq-local eldoc-documentation-function #'eldoc-documentation-default|compose|whatever))))
>
> BTW, using code like the one above is tolerable, usually for historical
> reasons, but new APIs should aim not to need such things: comparing
> functions is fundamentally always a hack.

So is run-time version checking, the risk is mostly the same.  But sure,
it's way uglier.  It's what needs to be done, as long as the package
developer want to support these features on a "as soon as possible"
basis _without_ adding the Eldoc core package as dependency.

But a simple version check on (< emacs-major-version 28) with two simple
branches works fine as well.

(if (< emacs-major-version 28)
    (the-before-until-thingy)
  (the-modern-thingy-but-no-comparing-functions))

Anyway, have you given thought to the possibility of having Eldoc.el
clobber the default value of eldoc-documentation-function if it finds it
unchanged?  This would just fix the case of Emacs < 28 && new eldoc for
developers who don't want to write the above snippet.  Not sure if it's
worth it, but Alex's original request goes in this direction.

Note that that all this mess has to do with the silliness that is having
eldoc.el be preloaded just becuase elisp-mode.el.  How would we go about
fixing that?

João




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 19:11:02 GMT) Full text and rfc822 format available.

Message #55 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 15:09:56 -0400
> Note that that all this mess has to do with the silliness that is having
> eldoc.el be preloaded just becuase elisp-mode.el.  How would we go about
> fixing that?

We could stop preloading `elisp-mode`.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 19:16:01 GMT) Full text and rfc822 format available.

Message #58 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 19:15:12 +0000
[Message part 1 (text/plain, inline)]
On Sun, Mar 28, 2021 at 8:09 PM Stefan Monnier <monnier <at> iro.umontreal.ca>
wrote:

> > Note that that all this mess has to do with the silliness that is having
> > eldoc.el be preloaded just becuase elisp-mode.el.  How would we go about
> > fixing that?
>
> We could stop preloading `elisp-mode`.


Even better, but can you say why it's even preloaded at all?
Certainly not somebody's whim, right?

João
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 19:37:01 GMT) Full text and rfc822 format available.

Message #61 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 15:36:05 -0400
>> > Note that that all this mess has to do with the silliness that is having
>> > eldoc.el be preloaded just becuase elisp-mode.el.  How would we go about
>> > fixing that?
>> We could stop preloading `elisp-mode`.
> Even better, but can you say why it's even preloaded at all?
> Certainly not somebody's whim, right?

The code for `emacs-lisp-mode` used to be in `lisp-mode.el` which also
contains various functions useful in all modes, so it's been preloaded
since before I started using Emacs.
When I moved (some of) the code to `progmodes/elisp-mode.el` I just
preserved that pre-existing situation.

I don't know for a fact, but based on my vague memory of what's in
`elisp-mode.el` I don't think there's a strong technical reason to
preload it.

IOW it's only preloaded because we expect it would be loaded sooner or
later anyway in many/most Emacs sessions.  I don't know if it's indeed
the case (tho it is clearly the case for *my* sessions), so you could
try to float the idea on `emacs-devel`.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 19:38:01 GMT) Full text and rfc822 format available.

Message #64 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 15:37:42 -0400
> Note that that all this mess has to do with the silliness that is having
> eldoc.el be preloaded just becuase elisp-mode.el.  How would we go about
> fixing that?

BTW, note also that the reason `eldoc.el` is preloaded is because
`global-eldoc-mode` is enabled by default, rather than because
`elisp-mode` is itself preloaded.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47388; Package emacs. (Sun, 28 Mar 2021 19:40:02 GMT) Full text and rfc822 format available.

Message #67 received at 47388 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Alex Branham <alex.branham <at> gmail.com>, 47388 <at> debbugs.gnu.org
Subject: Re: bug#47388: 27.1; eldoc-documentation-function is ignore in
 updated eldoc
Date: Sun, 28 Mar 2021 15:39:01 -0400
>>>   (when (function-equal #'ignore eldoc-documentation-function)
>>>         (setq-local eldoc-documentation-function
>>> #'eldoc-documentation-default|compose|whatever))))
>>
>> BTW, using code like the one above is tolerable, usually for historical
>> reasons, but new APIs should aim not to need such things: comparing
>> functions is fundamentally always a hack.
>
> So is run-time version checking, the risk is mostly the same.

I just wanted to make sure that it's only needed for backward
compatibility reasons.


        Stefan





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 26 Apr 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 338 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.