]> git.eshelyaron.com Git - emacs.git/commitdiff
Make newer ElDoc versions are compatible with Emacs < 28
authorJoão Távora <joaotavora@gmail.com>
Mon, 27 Jul 2020 21:07:38 +0000 (22:07 +0100)
committerJoão Távora <joaotavora@gmail.com>
Mon, 27 Jul 2020 21:18:57 +0000 (22:18 +0100)
Fixes: bug#42563
For some time, Eldoc has has some Elisp-specific code that shouldn't
live there, but in elisp-mode.el.  This can be fixed in Emacs master,
but since ElDoc is distributed in GNU Elpa and is meant to work with
Emacs 26 and 27, this means that that elisp-specific code must still
be distributed with eldoc.el and kept up to date.

* lisp/emacs-lisp/eldoc.el (eldoc--eval-expression-setup): Ensure
implementation is compatible with Emacs < 28.
(Version): Bump to 1.8

lisp/emacs-lisp/eldoc.el

index b30836cc0bd337b080745cb7ee26b26b7e74e9bb..19b3bd78aea7c12c33747e6ce785308c05e9a544 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Noah Friedman <friedman@splode.com>
 ;; Keywords: extensions
 ;; Created: 1995-10-06
-;; Version: 1.7.0
+;; Version: 1.8.0
 ;; Package-Requires: ((emacs "26.3"))
 
 ;; This is a GNU ELPA :core package.  Avoid functionality that is not
@@ -229,11 +229,15 @@ expression point is on." :lighter eldoc-minor-mode-string
 (defun eldoc--eval-expression-setup ()
   ;; Setup `eldoc', similar to `emacs-lisp-mode'.  FIXME: Call
   ;; `emacs-lisp-mode' itself?
-  (add-hook 'eldoc-documentation-functions
-            #'elisp-eldoc-var-docstring nil t)
-  (add-hook 'eldoc-documentation-functions
-            #'elisp-eldoc-funcall nil t)
-  (setq eldoc-documentation-strategy 'eldoc-documentation-default)
+  (cond ((<= emacs-major-version 27)
+         (declare-function elisp-eldoc-documentation-function "elisp-mode")
+         (add-function :before-until (local 'eldoc-documentation-function)
+                       #'elisp-eldoc-documentation-function))
+        (t (add-hook 'eldoc-documentation-functions
+                     #'elisp-eldoc-var-docstring nil t)
+           (add-hook 'eldoc-documentation-functions
+                     #'elisp-eldoc-funcall nil t)
+           (setq eldoc-documentation-strategy 'eldoc-documentation-default)))
   (eldoc-mode +1))
 
 ;;;###autoload