summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-13 00:54:26 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-13 00:54:26 +0100
commit1369b62d71e06735a3e4d2b8349cfffe6de12a6c (patch)
tree95a94341a018972758ccf602bdbc961daea5707a
parent432e405274205c91784456449f344044c8d62e48 (diff)
downloadgeiser-guile-1369b62d71e06735a3e4d2b8349cfffe6de12a6c.tar.gz
geiser-guile-1369b62d71e06735a3e4d2b8349cfffe6de12a6c.tar.bz2
Faster, asynchronous autodoc.
-rw-r--r--elisp/geiser-autodoc.el38
-rw-r--r--scheme/guile/geiser/emacs.scm2
-rw-r--r--scheme/guile/geiser/introspection.scm10
3 files changed, 33 insertions, 17 deletions
diff --git a/elisp/geiser-autodoc.el b/elisp/geiser-autodoc.el
index f5db63b..9c3c40b 100644
--- a/elisp/geiser-autodoc.el
+++ b/elisp/geiser-autodoc.el
@@ -67,13 +67,29 @@ when `geiser-autodoc-display-module-p' is on."
(make-variable-buffer-local
(defvar geiser-autodoc--last nil))
-(defun geiser-autodoc--function-args (fun)
- (if (eq fun (car geiser-autodoc--last))
- (cdr geiser-autodoc--last)
- (let ((result (geiser-eval--send/result `(:gs ((:ge proc-args) ',fun)))))
- (when (not (listp result)) (setq result 'undefined))
- (setq geiser-autodoc--last (cons fun result))
- result)))
+(make-variable-buffer-local
+ (defvar geiser-autodoc--last-funs nil))
+
+(defun geiser-autodoc--function-args (funs)
+ (let ((pr (and (eq (car geiser-autodoc--last) (caar funs)) (car funs))))
+ (if pr (geiser-autodoc--fun-args-str (car pr)
+ (cdr geiser-autodoc--last)
+ (cdr pr))
+ (setq geiser-autodoc--last-funs funs)
+ (geiser-eval--send `(:gs ((:ge arguments) ,@(mapcar (lambda (f) (list 'quote (car f)))
+ funs)))
+ 'geiser-autodoc--function-args-cont)
+ nil)))
+
+(defun geiser-autodoc--function-args-cont (ret)
+ (let ((result (geiser-eval--retort-result ret)))
+ (when (listp result)
+ (setq geiser-autodoc--last result)
+ (eldoc-message
+ (geiser-autodoc--fun-args-str (car result)
+ (cdr result)
+ (or (cdr (assoc (car result)
+ geiser-autodoc--last-funs))))))))
(defun geiser-autodoc--insert (sym current pos)
(let ((str (format "%s" sym)))
@@ -111,13 +127,7 @@ when `geiser-autodoc-display-module-p' is on."
;;; Autodoc function:
(defun geiser-autodoc--eldoc-function ()
- (let ((data (geiser-syntax--enclosing-form-data)))
- (catch 'doc-msg
- (dolist (f/a data)
- (let ((args (geiser-autodoc--function-args (car f/a))))
- (when (listp args)
- (throw 'doc-msg
- (geiser-autodoc--fun-args-str (car f/a) args (cdr f/a)))))))))
+ (geiser-autodoc--function-args (geiser-syntax--enclosing-form-data)))
;;; Autodoc mode:
diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm
index a3212af..79da237 100644
--- a/scheme/guile/geiser/emacs.scm
+++ b/scheme/guile/geiser/emacs.scm
@@ -25,7 +25,7 @@
;;; Code:
(define-module (geiser emacs)
- #:re-export (ge:proc-args
+ #:re-export (ge:arguments
ge:completions
ge:symbol-location
ge:compile-file
diff --git a/scheme/guile/geiser/introspection.scm b/scheme/guile/geiser/introspection.scm
index 38c0b79..efe9a09 100644
--- a/scheme/guile/geiser/introspection.scm
+++ b/scheme/guile/geiser/introspection.scm
@@ -25,11 +25,17 @@
;;; Code:
(define-module (geiser introspection)
- #:export (proc-args completions symbol-location)
+ #:export (arguments completions symbol-location)
#:use-module (system vm program)
#:use-module (ice-9 session)
#:use-module (srfi srfi-1))
+(define (arguments sym . syms)
+ (let loop ((sym sym) (syms syms))
+ (cond ((proc-args sym) => (lambda (args) (cons sym args)))
+ ((null? syms) #f)
+ (else (loop (car syms) (cdr syms))))))
+
(define (proc-args proc)
(obj-args (resolve-symbol proc)))
@@ -73,7 +79,7 @@
((pair? formals) (format-args (car formals)
(cdr formals)
(symbol-module name)))
- (else '()))))
+ (else #f))))
(define (macro-args macro)
(let ((prog (macro-transformer macro)))