summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-28 03:18:00 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-28 03:18:00 +0100
commitd05e8e0e2323a654e8e8f81214750b2819fcbc8e (patch)
tree4005c470b1a3eafa74c8d9b4697b99b3f4b0b6d6
parentf0e5d02619ead5688f051f14030cb700323e6c17 (diff)
downloadgeiser-guile-d05e8e0e2323a654e8e8f81214750b2819fcbc8e.tar.gz
geiser-guile-d05e8e0e2323a654e8e8f81214750b2819fcbc8e.tar.bz2
First stab at asynchronous autodoc retrieval
-rw-r--r--elisp/geiser-autodoc.el53
-rw-r--r--elisp/geiser-company.el2
-rw-r--r--elisp/geiser-eval.el6
3 files changed, 33 insertions, 28 deletions
diff --git a/elisp/geiser-autodoc.el b/elisp/geiser-autodoc.el
index a338bb9..567316d 100644
--- a/elisp/geiser-autodoc.el
+++ b/elisp/geiser-autodoc.el
@@ -57,31 +57,31 @@ when `geiser-autodoc-display-module-p' is on."
(defsubst geiser-autodoc--clean-cache ()
(setq geiser-autodoc--cached-signatures nil))
-(defun geiser-autodoc--get-signatures (funs &optional keep-cached)
+(defun geiser-autodoc--save-signatures (ret)
+ (let ((res (geiser-eval--retort-result ret)))
+ (when res
+ (setq geiser-autodoc--cached-signatures
+ (append (mapcar (lambda (s)
+ (cons (format "%s" (car s)) (cdr s)))
+ res)
+ geiser-autodoc--cached-signatures))))
+ (let ((str (geiser-autodoc--autodoc (geiser-syntax--scan-sexps)
+ geiser-autodoc--cached-signatures)))
+ (when str (eldoc-message str))))
+
+(defun geiser-autodoc--get-signatures (funs)
(when funs
- (let ((fs (assoc (car funs) geiser-autodoc--cached-signatures)))
- (unless fs
- (let ((missing) (cached))
- (if (not geiser-autodoc--cached-signatures)
- (setq missing funs)
- (dolist (f funs)
- (let ((cf (assoc f geiser-autodoc--cached-signatures)))
- (if cf (push cf cached)
- (push f missing)))))
- (unless (or cached keep-cached) (geiser-autodoc--clean-cache))
- (when missing
- (let* ((missing (mapcar 'make-symbol missing))
- (res (geiser-eval--send/result
- `(:eval (:ge autodoc (quote ,missing))) 500)))
- (when res
- (setq geiser-autodoc--cached-signatures
- (append (mapcar (lambda (s)
- (cons (format "%s" (car s)) (cdr s)))
- res)
- (if keep-cached
- geiser-autodoc--cached-signatures
- cached))))))))
- geiser-autodoc--cached-signatures)))
+ (let ((missing) (cached))
+ (if (not geiser-autodoc--cached-signatures)
+ (setq missing funs)
+ (dolist (f funs)
+ (let ((cf (assoc f geiser-autodoc--cached-signatures)))
+ (if cf (push cf cached) (push f missing)))))
+ (when missing
+ (let ((m (format "'(%s)" (mapconcat 'identity missing " "))))
+ (geiser-eval--send `(:eval (:ge autodoc (:scm ,m)))
+ 'geiser-autodoc--save-signatures)))
+ cached)))
(defun geiser-autodoc--sanitize-args (args)
(cond ((null args) nil)
@@ -166,9 +166,8 @@ when `geiser-autodoc-display-module-p' is on."
(insert ")")
(buffer-substring (point-min) (point))))))
-(defun geiser-autodoc--autodoc (path &optional keep-cached)
- (let ((signs (geiser-autodoc--get-signatures (mapcar 'car path)
- keep-cached))
+(defun geiser-autodoc--autodoc (path &optional signs)
+ (let ((signs (or signs (geiser-autodoc--get-signatures (mapcar 'car path))))
(p (car path))
(s))
(while (and p (not s))
diff --git a/elisp/geiser-company.el b/elisp/geiser-company.el
index b8381c9..8f7fca6 100644
--- a/elisp/geiser-company.el
+++ b/elisp/geiser-company.el
@@ -32,7 +32,7 @@
(ignore-errors
(if module
(format "%s [module]" id)
- (or (geiser-autodoc--autodoc (list (list (format "%s" id) 0)) t)
+ (or (geiser-autodoc--autodoc (list (list (format "%s" id) 0)))
(format "%s [local id]" id)))))
(defsubst geiser-company--doc-buffer (id module)
diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el
index 2ca20b4..8851e74 100644
--- a/elisp/geiser-eval.el
+++ b/elisp/geiser-eval.el
@@ -135,6 +135,12 @@ module-exports, autodoc, callers, callees and generic-methods.")
(defsubst geiser-eval--code-str (code)
(if (stringp code) code (geiser-eval--scheme-str code)))
+(defsubst geiser-eval--send (code cont &optional buffer)
+ (geiser-con--send-string (geiser-eval--connection)
+ (geiser-eval--code-str code)
+ cont
+ buffer))
+
(defvar geiser-eval--sync-retort nil)
(defun geiser-eval--set-sync-retort (s)
(setq geiser-eval--sync-retort (geiser-eval--log s)))