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

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

[nongnu] elpa/geiser-gauche f5ddefb 043/119: Prefer current-module visib


From: Philip Kaludercic
Subject: [nongnu] elpa/geiser-gauche f5ddefb 043/119: Prefer current-module visible alternatives in autodoc
Date: Sun, 1 Aug 2021 18:27:54 -0400 (EDT)

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

    Prefer current-module visible alternatives in autodoc
---
 geiser-gauche.el |  8 ++++++--
 geiser.scm       | 18 +++++++++++-------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/geiser-gauche.el b/geiser-gauche.el
index 572b25c..055a2bc 100644
--- a/geiser-gauche.el
+++ b/geiser-gauche.el
@@ -95,11 +95,15 @@
                         (t
                          "#f")))
           (form (mapconcat 'identity (cdr args) " ")))
-       (format "(eval '(geiser:eval %s '%s) (find-module 'geiser))" module 
form)))
+       ;; {{cur-module}} is replaced by the current module for the commands
+       (replace-regexp-in-string
+       "{{cur-module}}" module
+       (format "(eval '(geiser:eval %s '%s) (find-module 'geiser))" module 
form))))
     ;; The rest of the commands are all evaluated in the geiser module 
     (t
      (let ((form (mapconcat 'identity args " ")))
-       (format "(eval '(geiser:%s %s) (find-module 'geiser))" proc form)))))
+       ;; {{cur-module}} will be replaced by the current module when eval is 
called
+       (format "(eval '(geiser:%s %s {{cur-module}}) (find-module 'geiser))" 
proc form)))))
 
 (defconst geiser-gauche--module-re
   "(define-module +\\([[:alnum:].]+\\)")
diff --git a/geiser.scm b/geiser.scm
index 28fc78e..64742df 100644
--- a/geiser.scm
+++ b/geiser.scm
@@ -57,8 +57,8 @@
     (cut pprint (macroexpand form))))
 
 (define (geiser:eval module-name form . rest)
-  (call-with-output-file "/tmp/gauche.log"
-    (^o (format o "FORM: ~s, REST: ~s" form rest)))
+  ;; (call-with-output-file "/tmp/gauche.log" 
+  ;;   (^o (format o "FORM: ~s, REST: ~s" form rest)))
   (let* ((output (open-output-string))
          (module (or (and (symbol? module-name )
                          (find-module module-name))
@@ -136,11 +136,11 @@
 ;;; Autodoc
 
 (define (geiser:autodoc symbols . rest)
-  (map (cut formatted-autodoc <>)
+  (map (cut formatted-autodoc <> (car rest))
        symbols))
 
-(define (formatted-autodoc symbol)
-  (format-autodoc-signature (autodoc-signature symbol)))
+(define (formatted-autodoc symbol cur-module)
+  (format-autodoc-signature (autodoc-signature symbol cur-module)))
 
 (define (format-autodoc-signature as)
   (if (symbol? as)
@@ -155,10 +155,14 @@
 ;; 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)
+(define (autodoc-signature symbol cur-module)
   (let1 sigs (signatures symbol)
        (if (not (null? sigs))
-           (or (find (^x ($ not $ symbol? $ car x)) sigs)
+           ;; Prefer the binding which visible from the current module
+           (or (find (^x (eq? (global-variable-ref cur-module symbol #f)
+                              (global-variable-ref (cdr x) symbol #f)))
+                     sigs)
+               (find (^x ($ not $ symbol? $ car x)) sigs)
                (car sigs))
            symbol)))
 



reply via email to

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