summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames N. V. Cash <james.nvc@gmail.com>2020-09-17 10:51:13 -0400
committerKyle Meyer <kyle@kyleam.com>2020-09-20 21:24:55 -0400
commitc20cb0993b4139e50bf9e434863521e253f9a115 (patch)
tree2929e530e1cea354b391d727aefe9a5d242a1c30
parent3eccc537cdc0d39c33df668bba4278384f59aa5f (diff)
downloadorg-mode-c20cb0993b4139e50bf9e434863521e253f9a115.tar.gz
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.
-rw-r--r--contrib/lisp/org-eldoc.el29
1 files changed, 20 insertions, 9 deletions
diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 3b09993..946a572 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -1,4 +1,4 @@
-;;; org-eldoc.el --- display org header and src block info using eldoc
+;;; org-eldoc.el --- display org header and src block info using eldoc -*- lexical-binding: t; -*-
;; Copyright (c) 2014-2020 Free Software Foundation, Inc.
@@ -114,11 +114,18 @@
doc-func)
(if (eq 'empty cached-func)
(when (fboundp mode-func)
- (with-temp-buffer
- (funcall mode-func)
- (setq doc-func (and eldoc-documentation-function
- (symbol-value 'eldoc-documentation-function)))
- (puthash lang doc-func org-eldoc-local-functions-cache))
+ (with-temp-buffer
+ (funcall mode-func)
+ (setq doc-func (if (boundp 'eldoc-documentation-functions)
+ (let ((doc-funs eldoc-documentation-functions))
+ (lambda (callback)
+ (let ((eldoc-documentation-functions doc-funs))
+ (run-hook-with-args-until-success
+ 'eldoc-documentation-functions
+ callback))))
+ (and eldoc-documentation-function
+ (symbol-value 'eldoc-documentation-function))))
+ (puthash lang doc-func org-eldoc-local-functions-cache))
doc-func)
cached-func)))
@@ -127,7 +134,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 (&rest args)
"Return breadcrumbs when on a headline, args for src block header-line,
calls other documentation functions depending on lang when inside src body."
(or
@@ -160,8 +167,12 @@
(string= lang "go")
(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))))))))
+ (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))
+ (callback (car args)))
+ (when (functionp doc-fun)
+ (if (functionp callback)
+ (funcall doc-fun callback)
+ (funcall doc-fun)))))))))
;;;###autoload
(defun org-eldoc-load ()