org-eldoc: Fix compatibility with Emacs 28

* contrib/lisp/org-eldoc.el (org-eldoc-documentation-function): Accept
and ignore additional arguments for compatibility with Emacs 28.
(org-eldoc-load): Use add-function to register
org-eldoc-documentation-function for Emacs versions 25 through 27, as
documented in eldoc-documentation-function.

See Emacs's fd020a2931 (eldoc: modify `eldoc-documentation-function'
using `add-function', 2014-12-05) and c0fcbd2c11 (Expose ElDoc
functions in a hook (Bug#28257), 2020-02-25) for more information on
the Emacs 25 and Emacs 28 changes, respectively.
This commit is contained in:
Kyle Meyer 2020-07-17 01:29:36 -04:00
parent e62ca4a1bf
commit b2b587387e
1 changed files with 12 additions and 5 deletions

View File

@ -127,7 +127,7 @@
(declare-function php-eldoc-function "php-eldoc" ()) (declare-function php-eldoc-function "php-eldoc" ())
(declare-function go-eldoc--documentation-function "go-eldoc" ()) (declare-function go-eldoc--documentation-function "go-eldoc" ())
(defun org-eldoc-documentation-function () (defun org-eldoc-documentation-function (&rest _ignored)
"Return breadcrumbs when on a headline, args for src block header-line, "Return breadcrumbs when on a headline, args for src block header-line,
calls other documentation functions depending on lang when inside src body." calls other documentation functions depending on lang when inside src body."
(or (or
@ -161,11 +161,18 @@
(defun org-eldoc-load () (defun org-eldoc-load ()
"Set up org-eldoc documentation function." "Set up org-eldoc documentation function."
(interactive) (interactive)
(if (boundp 'eldoc-documentation-functions) ;; This approach is taken from python.el.
(add-hook 'eldoc-documentation-functions (with-no-warnings
#'org-eldoc-documentation-function nil t) (cond
((null eldoc-documentation-function) ; Emacs<25
(setq-local eldoc-documentation-function (setq-local eldoc-documentation-function
#'org-eldoc-documentation-function))) #'org-eldoc-documentation-function))
((boundp 'eldoc-documentation-functions) ; Emacs>=28
(add-hook 'eldoc-documentation-functions
#'org-eldoc-documentation-function nil t))
(t
(add-function :before-until (local 'eldoc-documentation-function)
#'org-eldoc-documentation-function)))))
;;;###autoload ;;;###autoload
(add-hook 'org-mode-hook #'org-eldoc-load) (add-hook 'org-mode-hook #'org-eldoc-load)