emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/geiser-gauche bdd8976 017/119: First version with working


From: Philip Kaludercic
Subject: [nongnu] elpa/geiser-gauche bdd8976 017/119: First version with working autocomplete
Date: Sun, 1 Aug 2021 18:27:49 -0400 (EDT)

branch: elpa/geiser-gauche
commit bdd897623e904b47c73bdf4e3158642ce4afdc29
Author: András Simonyi <andras.simonyi@gmail.com>
Commit: András Simonyi <andras.simonyi@gmail.com>

    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))
+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]