From 4c2042c9e3820d88cd655cf01d572b9686a40d31 Mon Sep 17 00:00:00 2001 From: "James N. V. Cash" Date: Thu, 17 Sep 2020 10:51:13 -0400 Subject: [PATCH] Address org-eldoc-recursion issue * org-eldoc.el (org-eldoc-get-mode-local-documentation-function, org-eldoc-documentation-function): Support Emacs 28-style eldoc, where instead of a single function, the eldoc-documentation-functions hook has a list of functions, which may optionally take a callback. --- contrib/lisp/org-eldoc.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el index 3b0999340..85e238e64 100644 --- a/contrib/lisp/org-eldoc.el +++ b/contrib/lisp/org-eldoc.el @@ -116,8 +116,13 @@ (when (fboundp mode-func) (with-temp-buffer (funcall mode-func) - (setq doc-func (and eldoc-documentation-function - (symbol-value 'eldoc-documentation-function))) + (setq doc-func (if (boundp 'eldoc-documentation-functions) + (lexical-let ((doc-funs (symbol-value 'eldoc-documentation-functions))) + (lambda () + (let ((eldoc-documentation-functions doc-funs)) + (funcall eldoc-documentation-strategy)))) + (and eldoc-documentation-function + (symbol-value 'eldoc-documentation-function)))) (puthash lang doc-func org-eldoc-local-functions-cache)) doc-func) cached-func))) @@ -127,7 +132,7 @@ (declare-function php-eldoc-function "php-eldoc" ()) (declare-function go-eldoc--documentation-function "go-eldoc" ()) -(defun org-eldoc-documentation-function (&rest _ignored) +(defun org-eldoc-documentation-function (&optional callback) "Return breadcrumbs when on a headline, args for src block header-line, calls other documentation functions depending on lang when inside src body." (or @@ -161,7 +166,12 @@ (string= lang "golang")) (when (require 'go-eldoc nil t) (go-eldoc--documentation-function))) (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))) - (when (functionp doc-fun) (funcall doc-fun)))))))) + (when (functionp doc-fun) + (if (functionp callback) + (condition-case nil + (funcall doc-fun callback) + (wrong-number-of-arguments (funcall doc-fun))) + (funcall doc-fun))))))))) ;;;###autoload (defun org-eldoc-load () -- 2.25.1