summaryrefslogtreecommitdiff
path: root/contrib/lisp/org-eldoc.el
diff options
context:
space:
mode:
authorSébastien Delafond <sdelafond@gmail.com>2016-11-07 10:41:54 +0100
committerSébastien Delafond <sdelafond@gmail.com>2016-11-07 10:41:54 +0100
commitec84430cf4e09ba25ec675debdf802bc28111e06 (patch)
tree9c64bc8a0cd5e8cac82aa5fdf369d40529f140f8 /contrib/lisp/org-eldoc.el
parent84539dca3aa301ecfe48858eceef1ced0505388b (diff)
Imported Upstream version 9.0
Diffstat (limited to 'contrib/lisp/org-eldoc.el')
-rw-r--r--contrib/lisp/org-eldoc.el26
1 files changed, 17 insertions, 9 deletions
diff --git a/contrib/lisp/org-eldoc.el b/contrib/lisp/org-eldoc.el
index 5583cb8..046918d 100644
--- a/contrib/lisp/org-eldoc.el
+++ b/contrib/lisp/org-eldoc.el
@@ -38,6 +38,10 @@
(require 'ob-core)
(require 'eldoc)
+(declare-function org-element-at-point "org-element" ())
+(declare-function org-element-property "org-element" (property element))
+(declare-function org-element-type "org-element" (element))
+
(defgroup org-eldoc nil "" :group 'org)
(defcustom org-eldoc-breadcrumb-separator "/"
@@ -70,7 +74,7 @@
(save-match-data
(when (looking-at "^[ \t]*#\\+\\(begin\\|end\\)_src")
(setq info (org-babel-get-src-block-info 'light)
- lang (propertize (nth 0 info) 'face 'font-lock-string-face)
+ lang (propertize (or (nth 0 info) "no lang") 'face 'font-lock-string-face)
hdr-args (nth 2 info))
(concat
lang
@@ -87,13 +91,17 @@
(defun org-eldoc-get-src-lang ()
"Return value of lang for the current block if in block body and nil otherwise."
- (let ((case-fold-search t))
- (save-match-data
- (when (org-between-regexps-p ".*#\\+begin_src"
- ".*#\\+end_src")
- (save-excursion
- (goto-char (org-babel-where-is-src-block-head))
- (car (org-babel-parse-src-block-match)))))))
+ (let ((element (save-match-data (org-element-at-point))))
+ (and (eq (org-element-type element) 'src-block)
+ (>= (line-beginning-position)
+ (org-element-property :post-affiliated element))
+ (<=
+ (line-end-position)
+ (org-with-wide-buffer
+ (goto-char (org-element-property :end element))
+ (skip-chars-backward " \t\n")
+ (line-end-position)))
+ (org-element-property :language element))))
(defvar org-eldoc-local-functions-cache (make-hash-table :size 40 :test 'equal)
"Cache of major-mode's eldoc-documentation-functions,
@@ -147,7 +155,7 @@
(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 (fboundp doc-fun) (funcall doc-fun))))))))
+ (when (functionp doc-fun) (funcall doc-fun))))))))
;;;###autoload
(defun org-eldoc-load ()