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

From: daanturo <[email-masked]>
Date: Thu, 10 Nov 2022 18:30:40 +0700

For Emacs < 27, after installing and loading the latest (1.13 currently)
eldoc, `eldoc-documentation-strategy` is set to `ignore` (along with
`eldoc-documentation-function`) unconditionally, whether it was set
before or not.

As a result, it even overrides user setting.

- Steps to reproduce:

```emacs-lisp
(when (< emacs-major-version 28)

  (package-initialize)

  (require 'eldoc)

  (unless (bound-and-true-p eldoc-documentation-strategy)
    (url-copy-file "https://elpa.gnu.org/packages/eldoc-1.13.0.tar"
                   "/tmp/eldoc-1.13.0.tar"
                   'ok)
    (package-install-file "/tmp/eldoc-1.13.0.tar"))

  (load "eldoc")

  (print (list (default-value 'eldoc-documentation-function)
               (default-value 'eldoc-documentation-strategy))))
```

- Observed: (ignore ignore)

- Expected: (eldoc-documentation-default eldoc-documentation-default)
(or the value of `eldoc-documentation-strategy` prior to loading)

Therefore unless explicitly set after that, or override locally,
supports targeted at the new eldoc will be futile.

For eglot as a workaround (I think so), `eldoc-documentation-strategy`
is even forcefully set locally [1] so user's choice is meaningless when
using eglot (even for Emacs>=28).

I propose that instead of forcing `eldoc-documentation-strategy` to
ignore, we respect user setting or set its default value to something
meaningful instead.

[1]: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/eglot.el?id=43db0e2784bfafdb8b08a2f5f075e2d432df132f#n1716

In GNU Emacs 27.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.30, cairo version 1.17.4)
of 2022-01-30 built on x64-builder02.almalinux.org
Windowing system distributor 'The X.Org Foundation', version 11.0.12201005
System Description: AlmaLinux 9.0 (Emerald Puma)

Recent messages:
Undo [2 times]

Configured using:
'configure --build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu --program-prefix=
--disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
--datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
--libexecdir=/usr/libexec --localstatedir=/var
--sharedstatedir=/var/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
--with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
--with-gpm=no --with-xwidgets --with-modules --with-harfbuzz
--with-cairo --with-json build_alias=x86_64-redhat-linux-gnu
host_alias=x86_64-redhat-linux-gnu CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2
-flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
-pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-Wp,-D_GLIBCXX_ASSERTIONS
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection
-fcf-protection' 'LDFLAGS=-Wl,-z,relro -Wl,--as-needed -Wl,-z,now
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 '
PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS
LIBSYSTEMD JSON PDUMPER GMP

Important settings:
value of $LANG: C.utf8
value of $XMODIFIERS: @im=fcitx
locale-coding-system: utf-8-unix

Major mode: TypeScript

Minor modes in effect:
corfu-indexed-mode: t
lsp-diagnostics-mode: t
lsp-headerline-breadcrumb-mode: t
lsp-modeline-workspace-status-mode: t
lsp-modeline-diagnostics-mode: t
lsp-modeline-code-actions-mode: t
lsp-completion-mode: t
lsp-managed-mode: t
lsp-mode: t
flymake-mode: t
savehist-mode: t
minibuffer-depth-indicate-mode: t
vertico-multiform-mode: t
vertico-mouse-mode: t
vertico-mode: t
electric-pair-mode: t
global-corfu-mode: t
corfu-mode: t
my-sgml-minor-mode: t
sgml-electric-tag-pair-mode: t
my-outline-comment-mode: t
my-outline-minor-highlight-mode: t
outline-minor-mode: t
flyspell-mode: t
display-line-numbers-mode: t
winner-mode: t
save-place-mode: t
global-auto-revert-mode: t
global-subword-mode: t
subword-mode: t
my-scroll-mode: t
delete-selection-mode: t
cua-mode: t
key-chord-mode: t
my-flyspell-global-mode: t
my-global-lsp-mode: t
my-pair-navigate-mode: t
my-global-pair-edit-mode: t
my-pair-edit-mode: t
my-minibuffer-input-history-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tab-bar-history-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
hs-minor-mode: t

Load-path shadows:
~/.local/state/emacs-27.2/elpaca-builds/ht/ht hides ~/.local/state/emacs-27.2/my-use-elisp/ht
~/.local/state/emacs-27.2/elpaca-builds/f/f-shortdoc hides ~/.local/state/emacs-27.2/my-use-elisp/f-shortdoc
~/.local/state/emacs-27.2/elpaca-builds/f/f hides ~/.local/state/emacs-27.2/my-use-elisp/f
~/.local/state/emacs-27.2/elpaca-builds/s/s hides ~/.local/state/emacs-27.2/my-use-elisp/s
~/.local/state/emacs-27.2/elpaca-builds/dash/dash hides ~/.local/state/emacs-27.2/my-use-elisp/dash
~/.local/state/emacs-27.2/my-use-elisp/compat hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat
~/.local/state/emacs-27.2/my-use-elisp/compat-help hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-help
~/.local/state/emacs-27.2/my-use-elisp/compat-font-lock hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-font-lock
~/.local/state/emacs-27.2/my-use-elisp/compat-28 hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-28
~/.local/state/emacs-27.2/my-use-elisp/compat-27 hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-27
~/.local/state/emacs-27.2/my-use-elisp/compat-26 hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-26
~/.local/state/emacs-27.2/my-use-elisp/compat-25 hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-25
~/.local/state/emacs-27.2/my-use-elisp/compat-24 hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-24
~/.local/state/emacs-27.2/my-use-elisp/compat-macs hides ~/.local/share/emacs-27/elpa/compat-28.1.2.2/compat-macs
~/.local/state/emacs-27.2/elpaca-builds/project/project hides ~/.local/share/emacs-27/elpa/project-0.8.2/project
~/.local/state/emacs-27.2/elpaca-builds/project/project-autoloads hides ~/.local/share/emacs-27/elpa/project-0.8.2/project-autoloads
~/.local/state/emacs-27.2/elpaca-builds/xref/xref hides ~/.local/share/emacs-27/elpa/xref-1.5.1/xref
~/.local/state/emacs-27.2/elpaca-builds/xref/xref-autoloads hides ~/.local/share/emacs-27/elpa/xref-1.5.1/xref-autoloads
~/.local/state/emacs-27.2/elpaca-builds/jsonrpc/jsonrpc hides /usr/share/emacs/27.2/lisp/jsonrpc
~/.local/state/emacs-27.2/elpaca-builds/project/project hides /usr/share/emacs/27.2/lisp/progmodes/project
~/.local/state/emacs-27.2/elpaca-builds/flymake/flymake hides /usr/share/emacs/27.2/lisp/progmodes/flymake
~/.local/state/emacs-27.2/elpaca-builds/xref/xref hides /usr/share/emacs/27.2/lisp/progmodes/xref
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-gvfs hides /usr/share/emacs/27.2/lisp/net/tramp-gvfs
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-sh hides /usr/share/emacs/27.2/lisp/net/tramp-sh
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp hides /usr/share/emacs/27.2/lisp/net/tramp
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-ftp hides /usr/share/emacs/27.2/lisp/net/tramp-ftp
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-archive hides /usr/share/emacs/27.2/lisp/net/tramp-archive
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-smb hides /usr/share/emacs/27.2/lisp/net/tramp-smb
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-uu hides /usr/share/emacs/27.2/lisp/net/tramp-uu
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-loaddefs hides /usr/share/emacs/27.2/lisp/net/tramp-loaddefs
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-adb hides /usr/share/emacs/27.2/lisp/net/tramp-adb
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/trampver hides /usr/share/emacs/27.2/lisp/net/trampver
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-compat hides /usr/share/emacs/27.2/lisp/net/tramp-compat
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-integration hides /usr/share/emacs/27.2/lisp/net/tramp-integration
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-cmds hides /usr/share/emacs/27.2/lisp/net/tramp-cmds
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-sudoedit hides /usr/share/emacs/27.2/lisp/net/tramp-sudoedit
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-cache hides /usr/share/emacs/27.2/lisp/net/tramp-cache
~/.local/share/emacs-27/elpa/tramp-2.5.3.3/tramp-rclone hides /usr/share/emacs/27.2/lisp/net/tramp-rclone
~/.local/state/emacs-27.2/my-use-elisp/seq hides /usr/share/emacs/27.2/lisp/emacs-lisp/seq
~/.local/state/emacs-27.2/elpaca-builds/eldoc/eldoc hides /usr/share/emacs/27.2/lisp/emacs-lisp/eldoc

Features:
(shadow sort mail-extr emacsbug message dired dired-loaddefs format-spec
rfc822 mml mml-sec epa derived gnus-util rmail rmail-loaddefs
text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils my-minibuffer-input-history-mode undo-fu
mule-util corfu-indexed time-date lsp-diagnostics lsp-headerline
lsp-icons lsp-modeline lsp-lens vc-mtn vc-hg vc-git diff-mode vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs vc vc-dispatcher view lsp-zig
lsp-steep lsp-svelte lsp-sqls lsp-yaml lsp-xml lsp-vimscript lsp-vhdl
lsp-vetur lsp-html lsp-verilog lsp-vala lsp-v lsp-toml lsp-terraform
lsp-tex lsp-sorbet lsp-solargraph lsp-rust lsp-rf lsp-r lsp-purescript
lsp-pylsp lsp-pyls lsp-pwsh lsp-php lsp-perl lsp-ocaml lsp-nix lsp-nim
lsp-nginx lsp-markdown lsp-lua lsp-kotlin lsp-json url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
mailcap lsp-javascript lsp-haxe lsp-groovy lsp-hack lsp-graphql lsp-go
lsp-completion lsp-gdscript lsp-fsharp lsp-fortran lsp-eslint lsp-erlang
lsp-elixir lsp-elm lsp-dockerfile lsp-dhall lsp-d lsp-css lsp-csharp
gnutls lsp-crystal lsp-cmake lsp-clojure lsp-semantic-tokens lsp-clangd
lsp-beancount lsp-bash lsp-angular lsp-ada lsp-actionscript lsp lsp-mode
lsp-protocol xref url-util tree-widget spinner network-stream puny nsm
rmc markdown-mode color lv inline imenu ht ewoc epg epg-config
flymake-proc flymake project warnings thingatpt
16-my-functions-file-directory 16-my-commands savehist mb-depth
vertico-multiform vertico-mouse vertico elec-pair corfu
16-my-functions-sgml sgml-mode dom my-sticky-header hideshow
my-outline-comment-mode noutline outline flyspell ispell
display-line-numbers typescript-mode rx cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs compile
comint ansi-color dash-autoloads s-autoloads f-autoloads ht-autoloads
spinner-autoloads markdown-mode-autoloads lv-autoloads eldoc-autoloads
lsp-mode-autoloads jsonrpc-autoloads xref-autoloads project-autoloads
flymake-autoloads eglot-autoloads my-init winner ring saveplace hl-line
autorevert filenotify my-config my-custom dracula-theme pcase cap-words
superword subword cus-edit cus-start cus-load wid-edit two-column delsel
cua-base key-chord 32-my-config-functions my-packages elpaca
elpaca-process elpaca-autoloads 08-other-package-managers
96-my-non-doom-init edmacro kmacro 01-my-core-functions f s
00-my-core-macros dash easy-mmode doom-lib compat compat-macs cl-extra
help-mode 00-my-lib-man info package easymenu browse-url url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib my-early-init tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win
x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting xwidget-internal cairo move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 548198 352741)
(symbols 48 34808 9)
(strings 32 213470 24052)
(string-bytes 1 4138067)
(vectors 16 55169)
(vector-slots 8 1396343 323498)
(floats 8 331 1144)
(intervals 56 902 346)
(buffers 1000 21))

-- 
Daanturo.
From b87148505c3d161cdd5556838611f59cd52ac913 Mon Sep 17 00:00:00 2001
From: Daanturo <[email-masked]>
Date: Thu, 10 Nov 2022 16:56:50 +0700
Subject: [PATCH] Don't set eldoc-documentation-strategy to ignore on Emacs<28

* 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..e463856bb1 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 (bound-and-true-p ,main)
+                                        #'eldoc-documentation-default)))
          (define-obsolete-variable-alias ',main ',secondary "eldoc-1.1.0"))
        (progn
          (defcustom ,main ,value ,docstring  ,@more)
-- 
2.38.1