summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2020-07-10 20:49:54 +0100
committerJoão Távora <joaotavora@gmail.com>2020-07-12 14:24:05 +0100
commit45d7db6d22e7caada63635aa3e627aad80b0d1e9 (patch)
treeb5378d458f3b9269912d22409cb89247cabe5a65 /lisp
parent7ee32966a951b2e07daf219da0f6f1eabf638a8a (diff)
downloademacs-45d7db6d22e7caada63635aa3e627aad80b0d1e9.tar.gz
emacs-45d7db6d22e7caada63635aa3e627aad80b0d1e9.tar.bz2
emacs-45d7db6d22e7caada63635aa3e627aad80b0d1e9.zip
Sort out ElDoc backward compatibility of eldoc-documentation-function
As explained previously, we can't simply make eldoc-documentation-function an variable alias for eldoc-documentation-strategy, because ElDoc is pre-loaded in Emacs < 28, where it holds at least one buffer-local binding. So if eldoc.el is loaded in those versions, we do the variable alias binding in reverse. We do this using a macro eldoc--documentation-strategy-defcustom to at load time in which direction to make the variable alias. * lisp/emacs-lisp/eldoc.el (eldoc--documentation-strategy-defcustom): Helper macro. (eldoc-documentation-strategy, eldoc-documentation-function): Use it. (Version): Bump to 1.5.0
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/eldoc.el27
1 files changed, 22 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index faf02aa0079..3a01d78cfe2 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -5,7 +5,7 @@
;; Author: Noah Friedman <friedman@splode.com>
;; Keywords: extensions
;; Created: 1995-10-06
-;; Version: 1.4.0
+;; Version: 1.5.0
;; Package-Requires: ((emacs "26.3"))
;; This is a GNU ELPA :core package. Avoid functionality that is not
@@ -539,10 +539,27 @@ Meant as a value for `eldoc-documentation-strategy'."
(if (stringp str) (funcall callback str))
nil))))
-(define-obsolete-variable-alias 'eldoc-documentation-function
- 'eldoc-documentation-strategy "eldoc-1.1.0")
-
-(defcustom eldoc-documentation-strategy #'eldoc-documentation-default
+;; JT@2020-07-10: Eldoc is pre-loaded, so in in Emacs < 28 we can't
+;; make the "old" `eldoc-documentation-function' point to the new
+;; `eldoc-documentation-strategy', so we do the reverse. This allows
+;; for Eldoc to be loaded in those older Emacs versions and work with
+;; whomever (major-modes, extensions, ueser) sets one of the other
+;; variable.
+(defmacro eldoc--documentation-strategy-defcustom
+ (main secondary value docstring &rest more)
+ "Defcustom helper macro for sorting `eldoc-documentation-strategy'."
+ (declare (indent 2))
+ `(if (< emacs-major-version 28)
+ (progn
+ (defcustom ,secondary ,value ,docstring ,@more)
+ (define-obsolete-variable-alias ',main ',secondary "eldoc-1.1.0"))
+ (progn
+ (defcustom ,main ,value ,docstring ,@more)
+ (defvaralias ',secondary ',main ,docstring))))
+
+(eldoc--documentation-strategy-defcustom eldoc-documentation-strategy
+ eldoc-documentation-function
+ #'eldoc-documentation-default
"How to collect and organize results of `eldoc-documentation-functions'.
This variable controls how `eldoc-documentation-functions', which