diff options
author | mathieu2em <math.per@hotmail.com> | 2019-07-23 10:57:26 -0400 |
---|---|---|
committer | mathieu2em <math.per@hotmail.com> | 2019-08-20 15:31:38 -0400 |
commit | e4370c6dfd8ef616defddb115402b385e2ec567d (patch) | |
tree | 10304366ad99f34f261c810d66c8e1bcedb1fc7b /scheme/gambit/geiser/gambit.scm | |
parent | 6805bbfd42248b51990422c4bc8a7370d9959dea (diff) | |
download | geiser-guile-e4370c6dfd8ef616defddb115402b385e2ec567d.tar.gz geiser-guile-e4370c6dfd8ef616defddb115402b385e2ec567d.tar.bz2 |
fix #1 ##decompile now tried before using the procedure's list
Diffstat (limited to 'scheme/gambit/geiser/gambit.scm')
-rw-r--r-- | scheme/gambit/geiser/gambit.scm | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/scheme/gambit/geiser/gambit.scm b/scheme/gambit/geiser/gambit.scm index ee3d78a..d8cae00 100644 --- a/scheme/gambit/geiser/gambit.scm +++ b/scheme/gambit/geiser/gambit.scm @@ -38,7 +38,83 @@ ((not (symbol? (car ids))) (geiser:autodoc (cdr ids))) (else - (list (##procedure-search (car ids)))))) + (geiser:new-autodoc (car ids))))) + ;;(list (##procedure-search (car ids)))))) + +;; (cadr (##decompile method)) format is +;;(#!optional (param1 (macro-absent-obj)) (param2 (macro-absent-obj)) #!rest others) +;; !! method-name -> procedure + +;; +(define (geiser:new-autodoc method-name) + (define (get-required lst) + (let loop ((lst lst) + (result '())) + (cond ((not (pair? lst)) + ;;(pp (cons (reverse result) '())) + ;;(pp "-----NEXT1-- not pair--") + (cons (reverse result) '())) + ((eq? (car lst) #!optional) + ;;(pp (cons (reverse result) (cdr lst))) + ;;(pp "-----NEXT1---opt--") + (cons (reverse result) (cdr lst))) + ((eq? (car lst) #!key) + ;;(pp (cons (reverse result) lst)) + ;;(pp "-----NEXT1--key---") + (cons (reverse result) lst)) + (else (loop (cdr lst) (cons (car lst) result)))))) + + (define (get-optional lst) + ;;(pp "getopt") + ;;(pp lst) + ;;(pp "----") + (let loop ((lst lst) + (result '())) + (cond ((or (not (pair? lst)) + (eq? (car lst) #!key)) + ;;(pp (cons (reverse result) + ;; (if (pair? lst) + ;; (cdr lst) + ;; '()))) + ;;(pp "------next2----key or emptylist--") + (cons (reverse result) + (if (pair? lst) + (cdr lst) + '()))) + ((eq? (car lst) #!rest) + ;;(pp (cons (reverse (cons '... result)) '())) + ;;(pp "-------next2---- rest--") + (cons (reverse (cons '... result)) '())) + (else + (loop (cdr lst) (cons (if (pair? (car lst)) (caar lst) (car lst)) result)))))) + + (define (get-key lst) + (let loop ((lst lst) + (result '())) + (cond ((not (pair? lst)) + result) + ((eq? (car lst) #!rest) + (reverse (cons '... result))) + (else (loop (cdr lst) (cons (car lst) result)))))) + + + (let ((proc (##global-var-ref (##make-global-var method-name)))) + (if (procedure? proc) + (let ((method-tester (##decompile proc))) + ;;(pp (cadr method-tester)) + ;;(pp "---NEXT---") + (if (pair? method-tester) + (let* ((method (cadr method-tester)) + (required (get-required method)) + (optional (get-optional (cdr required))) + (key (get-key (cdr optional)))) + (list `(,method-name + ("args" (("required" ,@(car required)) + ("optional" ,@(car optional)) + ("key" ,@key))) + ("module")))) + (list (##procedure-search method-name)))) + (list (##procedure-search method-name))))) (define (geiser:module-completions prefix . rest) (define (environment-symbols) |