[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-gauche 206f5be 045/119: Lots of cleanups
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-gauche 206f5be 045/119: Lots of cleanups |
Date: |
Sun, 1 Aug 2021 18:27:54 -0400 (EDT) |
branch: elpa/geiser-gauche
commit 206f5be0115d95cd15267a0b0d4c70d4099d7d95
Author: András Simonyi <andras.simonyi@gmail.com>
Commit: András Simonyi <andras.simonyi@gmail.com>
Lots of cleanups
---
geiser.scm | 92 +++++++++++++++++++++++++++++++-------------------------------
1 file changed, 46 insertions(+), 46 deletions(-)
diff --git a/geiser.scm b/geiser.scm
index cf3bf92..04c8a13 100644
--- a/geiser.scm
+++ b/geiser.scm
@@ -26,7 +26,7 @@
;; Utility functions
-;; Get the list of elements before the dot in a "dotted list" of the form
+;; Return the list of elements before the dot in a "dotted list" of the form
;; (x_1 x_2 ... x_n . y)
(define (dotted-list-head dl)
(if (pair? (cdr dl))
@@ -39,7 +39,7 @@
(get-first-leaf (car tree))
tree))
-;; Return coloned version of symbol
+;; Add a colon at the beginning to a symbol
(define (coloned-sym sym)
(if (string-prefix? ":" (symbol->string sym))
sym
@@ -111,9 +111,10 @@
symbol))
#f))
-;; Return a list of (signature module) pairs for all bindings of SYMBOL with
-;; signature. If SYMBOL is bound without the signature then the car is SYMBOL.
-(define (signatures symbol)
+;; Return a list of symbol-infos, i.e., (SIGNATURE-OR-SYMBOL MODULE) pairs for
+;; all bindings of SYMBOL. SIGNATURE-OR-SYMBOL is the signature of SYMBOL in
+;; MODULE if it can be found, and SYMBOL otherwise.
+(define (symbol-infos symbol)
(let ((signatures-w-modules
(map (^x (cons (signature-in-module symbol x)
(module-id x)))
@@ -121,15 +122,15 @@
(remove (^x (not (car x)))
signatures-w-modules)))
-;; Format a signature list for presenting with symbol documentation
-(define (format-signatures sigs)
+;; Format a symbol-info list for presenting with symbol documentation
+(define (format-symbol-infos symbol-infos)
(map (^x `(,(cdr x) ,(if (pair? (car x))
(car x)
`(,(car x) "..."))))
- sigs))
+ symbol-infos))
(define (geiser:symbol-documentation symbol . rest)
- `(("signature" ,(format-signatures (signatures symbol)))))
+ `(("signature" ,(format-symbol-infos (symbol-infos symbol)))))
;;; Autodoc
@@ -138,37 +139,30 @@
(map (cut formatted-autodoc <> (car rest))
symbols))
-(define (formatted-autodoc symbol cur-module)
- (format-autodoc-signature (autodoc-signature symbol cur-module)))
-
-(define (format-autodoc-signature as)
- (if (symbol? as)
- (list as)
- (let ((sig (car as))
- (module (cdr as)))
- (if (symbol? sig)
- `(,sig ("args" (("required" "...")))
- ("module" ,module))
- (signature->autodoc sig module)))))
-
-;; Return a (signature module) pair to be displayed in autodoc for SYMBOL.
-;; Return a (SYMBOL module) pair if SYMBOL is bound without signature and
-;; SYMBOL if no binding was found.
-(define (autodoc-signature symbol cur-module)
- (let1 sigs (signatures symbol)
- (if (not (null? sigs))
- ;; Prefer the binding which visible from the current module
- (or (find (^x (eq? (global-variable-ref cur-module symbol #f)
+(define (formatted-autodoc symbol pref-module)
+ (format-autodoc-symbol-info
+ (autodoc-symbol-info symbol pref-module)))
+
+;; Return a (SIGNATURE-OR-SYMBOL MODULE) pair or SYMBOL itself to be used in
the
+;; autodoc for SYMBOL. SIGNATURE-OR-SYMBOL is a signature of SYMBOL in MODULE
if
+;; it can be found, and SYMBOL otherwise. Only SYMBOL and not a pair is
returned
+;; if no suitable bindings were found. Prefer the binding which is visible from
+;; module PREF-MODULE, which should be a symbol.
+(define (autodoc-symbol-info symbol pref-module)
+ (let1 sis (symbol-infos symbol)
+ (if (not (null? sis))
+ (or (find (^x (eq? (global-variable-ref pref-module symbol #f)
(global-variable-ref (cdr x) symbol #f)))
- sigs)
- (find (^x ($ not $ symbol? $ car x)) sigs)
- (car sigs))
+ sis)
+ (find (^x ($ not $ symbol? $ car x)) sis)
+ (car sis))
symbol)))
-;; Format a signature for Geiser autodoc
-(define (signature->autodoc signature module-id)
-
- (define (process-normal-arg-info arg-info)
+
+;; Format an autodoc symbol-info in autodoc format.
+(define (format-autodoc-symbol-info asi)
+
+ (define (format-normal-arg-info arg-info)
(let ((required '("required"))
(optional '("optional"))
(key '("key"))
@@ -188,19 +182,25 @@
(else (push! required x))))))
(map (cut reverse <>)
(list required optional key))))
-
+
(define (process-dotted-arg-info arg-info)
`(("required" ,@(dotted-list-head arg-info) "...")
("optional")
("key")))
-
- `(,(car signature)
- ("args"
- ,((if (list? signature)
- process-normal-arg-info
- process-dotted-arg-info)
- (cdr signature)))
- ("module" ,module-id)))
+
+ (if (symbol? asi)
+ (list asi)
+ (let ((sig (car asi)) (module (cdr asi)))
+ (if (symbol? sig)
+ `(,sig ("args" (("required" "...")))
+ ("module" ,module))
+ `(,(car sig)
+ ("args"
+ ,((if (list? sig)
+ format-normal-arg-info
+ process-dotted-arg-info)
+ (cdr sig)))
+ ("module" ,module))))))
;; Further
- [nongnu] elpa/geiser-gauche 32b94a9 008/119: Remove diagnostic message, (continued)
- [nongnu] elpa/geiser-gauche 32b94a9 008/119: Remove diagnostic message, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 0de6385 025/119: Finish key argument handling in autodoc, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche dc40919 026/119: Correct a comment, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 652927a 041/119: Pass the module as a last argument to geiser: functions, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 698a685 038/119: Fix eval and compile, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 8adaf75 037/119: Improvements, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 5d8264b 033/119: Add (commented out) debugging logging of commands in *scratch*, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche a90a648 032/119: Implement module location, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 558a52e 034/119: Fix module-re, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 530f4f2 040/119: Add rest arguments to all geiser: procedures, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 206f5be 045/119: Lots of cleanups,
Philip Kaludercic <=
- [nongnu] elpa/geiser-gauche 6110849 067/119: Add dash to module name regex, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 060b7ee 062/119: Finish symbol location, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 9ffc5bd 058/119: Add comments, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 3d540b3 061/119: Symbol location work, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 2d2d29c 059/119: Reorder to silence an elisp compiler warning, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 5f4d1b5 070/119: Comment cleanup, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 362f1d1 071/119: Add LICENSE, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 9a26b8f 072/119: Aesthetic changes toward MELPA, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 83c9949 069/119: Minor improvement, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-gauche 93a7c9d 073/119: Add Cask file, Philip Kaludercic, 2021/08/01