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

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

[nongnu] elpa/geiser-gauche 8e737d2 110/119: Improve completion


From: Philip Kaludercic
Subject: [nongnu] elpa/geiser-gauche 8e737d2 110/119: Improve completion
Date: Sun, 1 Aug 2021 18:28:07 -0400 (EDT)

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

    Improve completion
---
 geiser-gauche.el  |  2 +-
 geiser-gauche.scm | 35 ++++++++++++++++++++++++++---------
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/geiser-gauche.el b/geiser-gauche.el
index 601bba3..2ac4e59 100644
--- a/geiser-gauche.el
+++ b/geiser-gauche.el
@@ -212,7 +212,7 @@
   (cl-case proc
     ;; Autodoc and symbol-location makes use of the {{cur-module}} cookie to
     ;; pass current module information
-    ((autodoc symbol-location)
+    ((autodoc symbol-location completions)
      (format "(eval '(geiser:%s %s {{cur-module}}) (find-module 'geiser))"
             proc (mapconcat 'identity args " ")))
     ;; Eval and compile are (module) context sensitive
diff --git a/geiser-gauche.scm b/geiser-gauche.scm
index 56f73d7..0f1b959 100644
--- a/geiser-gauche.scm
+++ b/geiser-gauche.scm
@@ -93,15 +93,29 @@
 
 ;;;; Completions
 
-(define (geiser:completions prefix . rest)
-  (delete-duplicates
-   (remove
-    (^x (or (string=? x "")
-           (string-prefix? "(" x)))
-    (string-split
-     (with-output-to-string
-       (cut apropos (string->regexp (string-append "^" prefix))))
-     #/\s+/))))
+(define (geiser:completions prefix m . rest)
+  (let* ((module (or (and (symbol? m )
+                         (find-module m))
+                    (find-module 'user)))
+        (symbols (module-visible-symbols module))
+        (strings (map symbol->string symbols)))
+    (filter! (cut string-prefix? prefix <>) strings)))
+
+;;; Return the list of symbols defined by MODULE
+(define (module-symbols module)
+  (hash-table-keys (module-table module)))
+
+;;; Return the list of symbols visible from MODULE   
+(define (module-visible-symbols module)
+  (let* ((imports (module-imports module))
+        (inherits (module-precedence-list module))
+        (imported-syms (concatenate!
+                        (map module-exports imports)))
+        (inherited-syms (concatenate!
+                         (map module-symbols inherits)))
+        (own-syms (module-symbols module)))
+    (delete-duplicates! (concatenate!
+                        (list imported-syms inherited-syms own-syms)))))
 
 (define (geiser:module-completions prefix . rest)
   (filter
@@ -265,3 +279,6 @@
                 `(("file" . ,(car paths)) ("line") ("column"))
                 '(("file") ("line") ("column"))))))
 
+
+
+



reply via email to

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