branch: elpa/geiser-gauche
commit bdd897623e904b47c73bdf4e3158642ce4afdc29
Author: András Simonyi <[email protected]>
Commit: András Simonyi <[email protected]>
First version with working autocomplete
---
geiser.scm | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/geiser.scm b/geiser.scm
index 780b2fb..879283e 100644
--- a/geiser.scm
+++ b/geiser.scm
@@ -42,11 +42,6 @@
(write `((result ,(write-to-string result))
(output . ,(get-output-string output))))))
-
-(define (geiser:autodoc ids . rest)
- (map (cut ~ <> 'info)
- ids))
-
(define (geiser:load-file filename)
(load filename))
@@ -79,8 +74,42 @@
(map (^x (symbol->string (module-name x)))
(all-modules))))
+;;; Autodoc
+
+(define (geiser:autodoc ids . rest)
+ (map (cut gauche-info <>)
+ ids))
+
+(define (gauche-info id)
+ (let ((module (find-module 'user)))
+ (if (global-variable-bound? 'user id)
+ (let1 obj (global-variable-ref (find-module 'user) id)
+ (if (is-a? obj <procedure>)
+ (process-info (~ obj 'info))
+ `(,id)))
+ `(,id))))
+
+(define (process-info info)
+ (let* ((required '("required"))
+ (optional '("optional"))
+ (key '("key"))
+ (section :required))
+ (dolist (x (cdr info))
+ (case x
+ ((:optional :key) (set! section x))
+ ((:rest))
+ (else (case section
+ ((:optional) (push! optional x))
+ ((:key) (push! key x))
+ (else (push! required x))))))
+ `(,(car info) ("args"
+ ,(map (cut reverse <>)
+ (list required optional key)))
+ ("module" user))))
+
;; Further
;; TODO We add the load-path at the end. Is this correct?
(define-macro (geiser:add-to-load-path dir)
`(add-load-path ,dir :after))
+