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

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

[nongnu] elpa/geiser-guile 943e58b 039/284: Miscellaneous little fixes.


From: Philip Kaludercic
Subject: [nongnu] elpa/geiser-guile 943e58b 039/284: Miscellaneous little fixes.
Date: Sun, 1 Aug 2021 18:29:12 -0400 (EDT)

branch: elpa/geiser-guile
commit 943e58b83a9c4da34754e8f737e59f2e5a496fc6
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>

    Miscellaneous little fixes.
---
 geiser/introspection.scm | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/geiser/introspection.scm b/geiser/introspection.scm
index c7b6de2..0a724f2 100644
--- a/geiser/introspection.scm
+++ b/geiser/introspection.scm
@@ -59,24 +59,30 @@
                (cons 'position (find-position args form))
                (cons 'module (symbol-module fun))))))
 
+(define (arglst args kind)
+  (let ((args (assq-ref args kind)))
+    (cond ((or (not args) (null? args)) '())
+          ((list? args) args)
+          (else (list args)))))
+
 (define (signature fun args)
-  (let ((req (assq-ref args 'required))
-        (opt (assq-ref args 'optional))
-        (key (assq-ref args 'keyword))
+  (let ((req (arglst args 'required))
+        (opt (arglst args 'optional))
+        (key (arglst args 'keyword))
         (rest (assq-ref args 'rest)))
-    (let ((sgn `(,fun ,@(or req '())
-                      ,@(if opt (cons #:optional opt) '())
-                      ,@(if key (cons #:key key) '()))))
+    (let ((sgn `(,fun ,@req
+                      ,@(if (not (null? opt)) (cons #:opt opt) '())
+                      ,@(if (not (null? key)) (cons #:key key) '()))))
       (if rest `(,@sgn #:rest ,rest) sgn))))
 
 (define (find-position args form)
   (let* ((lf (length form))
          (lf-1 (- lf 1)))
     (if (= 1 lf) 0
-        (let ((req (length (or (assq-ref args 'required) '())))
-              (opt (length (or (assq-ref args 'optional) '())))
+        (let ((req (length (arglst args 'required)))
+              (opt (length (arglst args 'optional)))
               (keys (map (lambda (k) (symbol->keyword (if (list? k) (car k) 
k)))
-                         (or (assq-ref args 'keyword) '())))
+                         (arglst args 'keyword)))
               (rest (assq-ref args 'rest)))
           (cond ((<= lf (+ 1 req)) lf-1)
                 ((<= lf (+ 1 req opt)) (if (> opt 0) lf lf-1))



reply via email to

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