Subject: Re: 27.2; eldoc-documentation-strategy being 'ignore prevents new eldoc supports

From: daanturo <[email-masked]>
Date: Thu, 10 Nov 2022 19:41:54 +0700

This version takes `eldoc-documentation-strategy`'s `default-value` to set
instead (the previous one may take the buffer-local value).

Another justification for the patch:

If `eldoc-documentation-strategy` is already set before loading the new eldoc,
loading the library will pop this warning up:

```
Warning (defvaralias): Overwriting value of ‘eldoc-documentation-strategy’ by aliasing to ‘eldoc-documentation-function’
```

By setting `eldoc-documentation-function` before defining
`eldoc-documentation-strategy` as alias, we can preserver its value of avoid
this warning.

By the way, why was `eldoc-documentation-strategy` made obsolete instead of
`eldoc-documentation-function`, isn't the latter's usage ough to be warned
against?

The second patch declares the correct obsolete one.

-- 
Daanturo.
From 1a695f0f1acdb537e7fa05bcbed5996ce1ee6ce2 Mon Sep 17 00:00:00 2001
From: Daanturo <[email-masked]>
Date: Thu, 10 Nov 2022 19:32:20 +0700
Subject: [PATCH 2/2] Eldoc on old Emacs: correct the obsolete variable

* lisp/emacs-lisp/eldoc.el (eldoc--documentation-strategy-defcustom):
make eldoc-documentation-function the obsolete one instead of
eldoc-documentation-strategy.
---
 lisp/emacs-lisp/eldoc.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index d5d46446eb..2356a8e024 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -697,7 +697,8 @@ This is meant to be used as a value for `eldoc-documentation-strategy'."
            ;; restore user setting, or our default
            (setq-default ,secondary (or (and (boundp ',main) (default-value ',main))
                                         #'eldoc-documentation-default)))
-         (define-obsolete-variable-alias ',main ',secondary "eldoc-1.1.0"))
+         (defvaralias ',main ',secondary)
+         (make-obsolete-variable ',secondary ',main  "eldoc-1.14.0"))
        (progn
          (defcustom ,main ,value ,docstring  ,@more)
          (defvaralias ',secondary ',main ,docstring))))
-- 
2.38.1

From e5e27868a7671d8d52c5920b286bf22a2cc9aac5 Mon Sep 17 00:00:00 2001
From: Daanturo <[email-masked]>
Date: Thu, 10 Nov 2022 16:56:50 +0700
Subject: [PATCH 1/2] Don't set eldoc strategy to ignore on Emacs 27 and below

* lisp/emacs-lisp/eldoc.el (eldoc--documentation-strategy-defcustom): on
Emacs 27 and below, prevent eldoc-documentation-strategy (an alias of
eldoc-documentation-function) being set to 'ignore globally.
---
 lisp/emacs-lisp/eldoc.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index e1801c45b7..d5d46446eb 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -691,6 +691,12 @@ This is meant to be used as a value for `eldoc-documentation-strategy'."
   `(if (< emacs-major-version 28)
        (progn
          (defcustom ,secondary ,value ,docstring ,@more)
+         ;; `eldoc-documentation-strategy' being `ignore' invalidates
+         ;; supports for it
+         (when (equal (default-value ',secondary) #'ignore)
+           ;; restore user setting, or our default
+           (setq-default ,secondary (or (and (boundp ',main) (default-value ',main))
+                                        #'eldoc-documentation-default)))
          (define-obsolete-variable-alias ',main ',secondary "eldoc-1.1.0"))
        (progn
          (defcustom ,main ,value ,docstring  ,@more)
-- 
2.38.1